Question

issue in connecting to PSQL

Posted October 26, 2021 130 views
PostgreSQLReact

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?

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.

×
Submit an Answer
1 answer

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:

https://docs.digitalocean.com/products/app-platform/how-to/troubleshoot-app/