skip to Main Content

enter image description hereleft is my docker-compose.yml and right that my docker is up and still I cannot access the database.

Can you tell me how can I alternately connect to the postgres database in docker (remember I am using Windows 11 OS)

  version: '3.8'
services:
  dev-db :
    image : postgres:13
    ports : 
      - "5434"
    environment : 
      POSTGRES_USER : postgres
      POSTGRES_PASSWORD : eresto
      POSTGRES_DB : eresto
    networks :
      - 4s
networks:
  4s:
C:UserssrikaTestProgramsE-Restoe-resto-api>npx prisma migrate dev

Environment variables loaded from .env
Prisma schema loaded from prismaschema.prisma
Datasource "db": PostgreSQL database "eresto", schema "public" at "localhost:5434"

Error: P1001: Can’t reach database server at localhost:5434

Please make sure your database server is running at localhost:5434.

2

Answers


  1. Chosen as BEST ANSWER

    at ports "5432:5432" worked for me.

    What the concept is, to expose the localhost server and put the ports in string.


  2. You have not exposed the database on your host machine.

    Please set the ports like this in your docker-compose.yml file:

    version: '3.8'
    
    services:
      dev-db:
        image: postgres:13
        ports:
          # Exposed on 5434 - but Postgres internally
          # lives on port 5432 (that is the default)
          - 5434:5432
        environment: 
          - POSTGRES_USER=postgres
          - POSTGRES_PASSWORD=eresto
          - POSTGRES_DB=eresto
        networks:
          - 4s
    
    networks:
      4s:
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search