Dennis
Dennis

Reputation: 1

Prisma Error: P1001: Can't reach database server at `localhost`:`5432` with docker-compose

i get this error message on Windows 11 when I try to run the "npx prisma migrate dev". For me the config looks right maybe someone can help me.

docker-compose.yml:

version: "3.8"

services:

  db:
    image: postgres
    container_name: postgres
    restart: always    
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PW}
    volumes:
      - postgres:/var/lib/postgresql/data
    ports:
      - 5432:5432
    env_file:
      - .env
    expose:
      - 5432

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

volumes:
  postgres:
  adminer: 

Error:

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

docker ps: enter image description here

If I specify only one port 5432 and docker assigns an automatic port e.g. 0.0.0.0:55156->5432/tcp and then I change the port in my connenction-string to 55156, I can run npx prisma migrate command successfully.

Also i can access localhost:8080 in the browser without problems, the two ports are also mapped in the config.

Upvotes: 0

Views: 1961

Answers (1)

Dennis
Dennis

Reputation: 1

I found a solution that worked for me!

After uninstalling postgres (https://www.postgresql.org/) from my windows system, everything is running as expected.

Upvotes: 0

Related Questions