notiz-dev / nestjs-prisma-docker

Dockerizing a NestJS app with Prisma and PostgreSQL
https://notiz.dev/blog/dockerizing-nestjs-with-prisma-and-postgresql
93 stars 28 forks source link

Cannot find the database server #15

Closed danieltwork closed 2 years ago

danieltwork commented 2 years ago

After launch: docker-compose up

it receives this error:

(node:21) UnhandledPromiseRejectionWarning: Error: Can't reach database server at `postgresprisma`:`5432`
nest-api    |
nest-api    | Please make sure your database server is running at `postgresprisma`:`5432`.
nest-api    |     at /node_modules/@prisma/client/runtime/index.js:36260:21
nest-api    | (Use `node --trace-warnings ...` to show where the warning was created)
nest-api    | (node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
nest-api    | (node:21) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The database container started correctly, but the API container starts with an error.

marcjulian commented 2 years ago

@danieltwork can you add your docker-compose file here too?

danieltwork commented 2 years ago

@marcjulian I am running this using docker-compose from your respository

marcjulian commented 2 years ago

Okay, i cloned the repo and run the docker-compose. I don't get the above error of yours. Do you have the postgres db and the nest api running as a docker container?

Screenshot 2022-08-19 at 13 07 30

You probably also copied .env.example as .env?

danieltwork commented 2 years ago

@marcjulian There seems to have been a problem unrelated to the repository. I checked some other similar projects and they were causing the same problem. It fixed itself :) :magic: