Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL for PostgreSQL connection nodejs

I am trying to connect to my Heroku PostgreSQL DB and I keep getting an SSL error. Does anyone have an idea on how to enable SSL in the connection string?

postgres://user:pass@host:port/database; 

Been looking for it everywhere but it does not seem to be a very popular topic. By the way, I am running Nodejs and the node-pg module with its connection-pooled method:

pg.connect(connString, function(err, client, done) {   // Should work. }); 

Comments are much appreciated.

like image 439
Stefan Avatar asked Mar 10 '14 13:03

Stefan


People also ask

How do I connect to PostgreSQL SSL?

With SSL support compiled in, the PostgreSQL server can be started with SSL enabled by setting the parameter ssl to on in postgresql. conf. The server will listen for both normal and SSL connections on the same TCP port, and will negotiate with any connecting client on whether to use SSL .

How do you check if SSL is enabled on Postgres?

Verify SSL is EnabledVerify the configuration file for Postgres has the ca file configured cat /db/postgresql/*/data/postgresql. conf | grep 'ssl' . If the configuration file shows SSL is on and the server indicated it was off you'll need to Restart PostgreSQL.


1 Answers

You can achieve this like this:

postgres://user:pass@host:port/database?ssl=true 
like image 168
Jérôme Verstrynge Avatar answered Oct 07 '22 17:10

Jérôme Verstrynge