-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cannot connect to the databse #24
Comments
Hi @bartekpacia can you post your docker-compose.yaml file too? What is the container name of the database? |
Thanks for such a quick response! Here's my .env (the one posted above had incorrect host):
Here's my version: '3.8'
services:
nest-api:
build:
context: .
dockerfile: Dockerfile
container_name: nest-api
restart: always
ports:
- 3000:3000
depends_on:
- postgres
env_file:
- .env
postgres:
image: postgres:13
container_name: postgresprisma
restart: always
ports:
- 5432:5432
env_file:
- .env
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
name: nest-prisma-docker-db But I'm getting the same error with curl:
|
When you serve the nest api and set the connection name to What if you trie to set the service and container name to the same name e.g.
https://notiz.dev/blog/dockerizing-nestjs-with-prisma-and-postgresql/#add-docker-compose-with-postgresql |
When I change the DATABASE_URL to use host
When I use the same name for both service and container_name (=
|
Use The error message when you use |
Here's my
|
Or maybe do you mean to check whether the
|
I did the same steps which were mentioned in this comment and I have the same problem as Bartek with error as below:
|
For future readers: we got it to work! Here's our Dockerfile and docker-compose.yaml. |
Hi, thank you for publishing this sample repo.
I'm having a problem - the app container doesn't connect to the database container.
Reproduction steps
.env
file so it looks like this:docker compose up
curl http://localhost:3000/foods
I'm getting
{"statusCode":500,"message":"Internal server error"}%
in curl output.Here are logs:
Details
I'll be very grateful for any help! I cannot seem to make Prisma work properly in my containerized Nest.js app.
The text was updated successfully, but these errors were encountered: