skip to Main Content

I’m following a tutorial on NestJS and it uses Docker to deploy the database (locally). I’m totally new with Docker by the way.

As an ORM, it uses Prisma.

My Docker container launches, "ready to accept connections", but when I do npx prisma migrate dev, it returns ->

Error: P1001: Can’t reach database server at localhost:5434
Please make sure your database server is running at localhost:5434.

Here’s the DATABASE_URL situated in a .env file (I added the connect_timeout after some searches on internet but it didn’t solve the problem) :

DATABASE_URL="postgresql://postgres:123@localhost:5434/nest?schema=public?connect_timeout=300"

Here’s my docker-compose.yml :
docker-compose.yml

2

Answers


  1. The postgres default port is 5432, not 5431. Try to change it in docker-compose.yml

    Login or Signup to reply.
  2. I am following the same tutorial. I had this error as well.
    I fixed it by simply deleting the migrations folder inside the prisma folder and then run npx prisma migrate dev again.

    1. Delete the migrations folder inside the prisma folder
    2. run npx prisma migrate dev

    What I noticed is that, the error is caused by this command

    db:dev:rm": "docker compose rm dev-db -s -f -v in your package.json

    I don’t know why though but you may need to avoid using it.

    I hope this is helpful.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search