nestjs-api-tutorial icon indicating copy to clipboard operation
nestjs-api-tutorial copied to clipboard

Error: P1001: Can't reach database server at `localhost`:`5432`

Open righes opened this issue 3 years ago • 1 comments

I have a probleme to connect to the postgres on docker. I have the env :: DATABASE_URL="postgresql://postgres:123@localhost:5432/nest?schema=public" and the docker-compose :: version: '3.8' services: dev-db: image: postgres:13 ports: - 5434:5432 environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: 123 POSTGRES_DB: nest networks: - freecodecamp networks: freecodecamp: I do on the terminal :: npx prisma migrate dev i have :: Error: P1001: Can't reach database server at localhost:5432

righes avatar Jul 18 '22 16:07 righes

Hi @righes As far as I can tell, you seem to be using the wrong port in your code. inside your docker configuration you have specified port 5434 as the external port for the DB container whereas in your code, you are using port 5432 to connect to the DB

s3000-f avatar Sep 02 '22 20:09 s3000-f