Authentication error when connecting to Heroku PostgreSQL database
Solved it by setting PGSSLMODE
(http://www.postgresql.org/docs/9.0/static/libpq-envars.html) on Heroku. It tells PostgreSQL to default to SSL.
$ heroku config:set PGSSLMODE=require
node-postgres doesn't support SSL in it's javascript bindings, which you're using if you do:
var pg = require('pg');
To get SSL, you need to use the native binding by doing this:
var pg = require('pg').native;
You don't need to use SSL when your app is running inside Heroku, you only need to use SSL to connect remotely (when your app is running locally).
I added these params and can now connect to my heroku postgres instance from an outside server, specifically, in configuration of knex.js in a node express server:
var knex = require('knex')({ client: 'postgres', connection: 'postgres://username:password@host:5432/yourdbname?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory'});