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

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.

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;

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel