issue in connecting to PSQL

I am creating a website using app platform, but my node.js component cant connect to my PSQL database. I’ve keyed in my environment variable to connect to it, but in the console it said:

psql: error: could not connect to server

how do I solve this?

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.

Hi @syedridhwan96,

I assume that you have enabled trusted sources and added the App ID under the trusted sources list. If not then please make sure the App ID is added and allowed to connect to the database.

Once you configure to allow the app in the managed database then you should be able to connect to the database in the deploy phase and runtime however database connection in the build phase will be restricted. DigitalOcean does not recommend the database connection during a build so you can use pre-deploy jobs to connect to the database and perform any tasks/migration.

Additionally, I’ll urge you to check the following documentation, I think it might be of help as well: