SSL for PostgreSQL connection nodejs

Stefan picture Stefan · Mar 10, 2014 · Viewed 38.3k times · Source

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.

Answer

Jérôme Verstrynge picture Jérôme Verstrynge · Jul 25, 2014

You can achieve this like this:

postgres://user:pass@host:port/database?ssl=true