Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 839
Juan-Rivera Avatar asked Mar 05 '21 17:03

Juan-Rivera


Video Answer


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",
},
like image 141
Josh Gorton Avatar answered Oct 26 '22 10:10

Josh Gorton