By ericCrab
I am using environment variables to connect to by database through a Node.js webapp. When a submit a request to my database I get a 504 Gateway Time-out error. I checked my pm2 logs, and I am getting the following error "no pg_hba.conf entry for host “<myIP>”, user “<myusername>”, database “<mydatabase>”, SSL off.
Here are my environment variables
PGUSER=<myusername> PGHOST=<myhost> PGPASSWORD=<mypassword> PGDATABASE=<mydatabase> PGPORT=<myport> PGSSLMODE=true NODE_ENV=production
All of those are copied from the connection parameters provided to me by digital ocean. The managed database is SSL = require, but when I change PGSSLMODE to =require, I get the following pm2 log error “self signed certificate in certificate chain”.
I also tried setting the connection string provided to me as the environmental variable connection: to see if that would work, but that gave me the following error “connect ECONNREFUSED 127.0.0.1:5432”. My digital ocean managed database is not 5432, which I know is the default Postgres port, so it makes me think that it isn’t seeing that environment variable.
Any help is appreciated, and please let me know if you need more context!
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!
Hi there,
You would indeed need to set the SSL to required, but in order to fix the self-signed certificate error.
You will have to also download the .crt file for your Managed Cluster from your DigitalOcean control panel and add it to your server.
That way your Node application will use the CA certificate and you will not get the SSL error.
Let me know how it goes. Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.