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

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

我的 knexfile.js 中的生产设置如下所示:

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

我试过添加 ssl: truefalse 并且还添加了 ssl: {rejectUnauthorized: false } 无济于事。这对我来说从来都不是问题,所以不确定为什么会不断发生此错误。感谢您的帮助!

我遇到了完全相同的问题,最终找到了解决方法:

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

最终,我所要做的就是在 Heroku 仪表板上添加建议的环境变量。 (PGSSLMODE=no-verify)

Heroku Config Vars

还值得一提的是,我确保在我的 package.json 文件中包含最新版本的 PG 和 Knex

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