Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error happened when run wasp db migrate-dev #347

Open
feitian124 opened this issue Dec 21, 2024 · 2 comments
Open

error happened when run wasp db migrate-dev #347

feitian124 opened this issue Dec 21, 2024 · 2 comments

Comments

@feitian124
Copy link

feitian124 commented Dec 21, 2024

i am running postgre by WSL2 in ubuntu 24.04, and i am using docker desktop for windows.

when i run wasp start db, it report below error. but i do not on any process on wsl2 or windows for port 5432.

± |master ?:2 ✗| → wasp start db
✨ Starting a PostgreSQL dev database (based on your Wasp config) ✨

Additional info:
 ℹ Connection URL, in case you might want to connect with external tools:
     postgresql://postgresWaspDevUser:postgresWaspDevPass@localhost:5432/OpenSaaS-bba774dce6
 ℹ Database data is persisted in a docker volume with the following name (useful to know if you will want to delete it at some point):
     wasp-dev-db-OpenSaaS-bba774dce6

...
docker: Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:5432 -> 0.0.0.0:0: listen tcp 0.0.0.0:5432: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
wasp-bin: callCommand: docker run --name wasp-dev-db-OpenSaaS-bba774dce6 --rm --publish 5432:5432 -v wasp-dev-db-OpenSaaS-bba774dce6:/var/lib/postgresql/data --env POSTGRES_PASSWORD=postgresWaspDevPass --env POSTGRES_USER=postgresWaspDevUser --env POSTGRES_DB=OpenSaaS-bba774dce6 postgres (exit 125): failed

i try run bare docker command directly, it works this time.

 2024-12-22 03:03:37 ⌚  ming-r7000 in ~/github/feitian124/wearit/app
± |master ?:2 ✗| → sudo docker run --name wasp-dev-db-OpenSaaS-bba774dce6 --rm --publish 5432:5432 -v wasp-dev-db-OpenSaaS-bba774dce6:/var/lib/postgresql/data --env POSTGRES_PASSWORD=postgresWaspDevPass --env POSTGRES_USER=postgresWaspDevUser --env POSTGRES_DB=OpenSaaS-bba774dce6 postgres

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-12-21 19:03:43.907 UTC [1] LOG:  starting PostgreSQL 17.2 (Debian 17.2-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-12-21 19:03:43.911 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-12-21 19:03:43.922 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-12-21 19:03:43.932 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-12-21 19:03:43.943 UTC [29] LOG:  database system was shut down at 2024-12-21 18:24:50 UTC
2024-12-21 19:03:43.958 UTC [1] LOG:  database system is ready to accept connections

but later steps report error too:

± |master ?:2 ✗| → wasp db migrate-dev
🐝 --- Setting up database... -----------------------------------------------------


[   Db  !] Error: P1001
[   Db  !]
[   Db  !] Can't reach database server at `localhost:5432`
[   Db  !]
[   Db  !] Please make sure your database server is running at `localhost:5432`.
[   Db  !]
[   Db   ] Environment variables loaded from .env
[   Db   ] Prisma schema loaded from ../db/schema.prisma
[   Db   ]
[   Db   ] ✔ Generated Prisma Client (v5.19.1) to ./../../../node_modules/@prisma/client in 116ms
❌ --- [Error] Can not connect to database: ---------------------------------------

The database needs to be running in order to execute this command. You can easily start a managed dev database with `wasp start db`.

i run wasp db studio, i can see my database are runing and can see studio page,
obviously my database is running on 5432, not sure why wasp db migrate-dev and wasp start not work.

does anyone met same problem?
and also, does this repo support sqlite?
thank you.

@vincanger
Copy link
Collaborator

Maybe @martinovicdev, our resident WSL hacker, or @Martinsos know what to do here?

@martinovicdev
Copy link
Collaborator

This could have been caused by the incomplete Docker Desktop installation. Here is a step by step guide based on official Docker guide https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user:

  1. Run
    sudo groupadd docker
    If the group exists, continue with the following steps anyways.

  2. Now add your user to docker group by running
    sudo usermod -aG docker $USER
    where USER is your username. In my case, it would be sudo usermod -aG docker martinovicdev

  3. Now log out and log back in to the WSL2 shell. Run
    su -s $USER

  4. Now try out the wasp db start command and it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants