Below NodeJS code works fine when I deploy to Heroku.
var pgp = require("pg-promise")(/*options*/); function PostgresDBAdapter() { var db = pgp(