Question

PrismaClientInitializationError: Can't reach database server at `db`:`5432`

I have a project on Nest.js that I want to deploy to DigitalOcean apps. I am creating several containers (database container and app container). As database I use postgresql, ORM is prisma. But while I am trying to deploy my project I get an error that says that my database is not running in the given server (PrismaClientInitializationError: Can’t reach database server at db:5432).‘db’ is the name of my container that creates in docker-compose.yml file. What could be the problem causing this? I tried to change the server name (‘db’) to my application server name, but it did not solved the problem.


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
January 8, 2023

Hi @akifmursalov,

The Firewall/Authorized Access always comes to mind when someone is experiencing such issues.

See if you have allowed access to the said Database from the place where you are connecting.

What is your Database connection string? To where it should connect to, are you using DigitalOcean’s Managed Database? If yes, check the following tutorial on how to connect;

https://docs.digitalocean.com/products/databases/postgresql/how-to/connect/