Heroku Postgres not able to connect ERROR: no pg_hba.conf entry for host "...", user "...", database "...", SSL off

Viewed 1906

My production setup in my knexfile.js looks like this:

production: {
client: 'pg',
connection: process.env.DATABASE_URL,
migrations: {
  directory: './data/migrations'
},
seeds: {
  directory: './data/seeds'
},

I have tried adding ssl: true and false and also added ssl: {rejectUnauthorized: false } to no avail. This has never been an issue for me before so not sure why this error keeps happening. Any help is appreciated!

1 Answers

I was having the same exact issue and finally found my way to:

https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md#pg810

Ultimately, all I had to do was to add the suggested Environment variable on the Heroku dashboard. (PGSSLMODE=no-verify)

Heroku Config Vars

It's also worth mentioning that I made sure to have the most recent versions of both PG and Knex in my package.json file

"dependencies": {
    "knex": "^0.95.1",
    "pg": "^8.5.1",
},
Related