Royer Adames
Royer Adames

Reputation: 1076

heroku knex migration/seed error: no pg_hba.conf entry for host ssl false

Trying to use the Heroku console to run knex migration and seeds. Everything works in the development environment but it doesn't in Heroku. I get an SSL error and I don't know how to solve it without paying for a higher database tier.

Upvotes: 0

Views: 457

Answers (2)

tlenex
tlenex

Reputation: 517

Resolved with:

{
  production: {
    client: 'pg',
    connection: {
      connectionString: process.env.DATABASE_URL,
      ssl: {
        rejectUnauthorized: false,
      },
    },
  },
}

Upvotes: 0

Royer Adames
Royer Adames

Reputation: 1076

Because node-Postgres enables SSL validation by default while free Heroku hosting doesn’t provide it automatically, you need to turn it off. disable SSL in Heroku: enter image description here

CLI solution:

heroku config:set PGSSLMODE=no-verify --app <app name>

Sources:

https://dpletzke.medium.com/configuring-free-heroku-node-postgresql-hosting-with-knex-b0e97a05c6af

https://help.heroku.com/DR0TTWWD/seeing-fatal-no-pg_hba-conf-entry-errors-in-postgres

Upvotes: 1

Related Questions