连接 Heroku PostgreSQL 数据库时出现身份验证错误

2023-12-22

我正在使用 PostgreSQL 开发一个 Node.js 应用程序并托管在 Heroku 上。我的问题是我收到如下身份验证错误:

14:32:05 web.1     | { [error: no pg_hba.conf entry for host "193.40.244.196", user "username", database "database_name", SSL off]
14:32:05 web.1     |   length: 168,
14:32:05 web.1     |   name: 'error',
14:32:05 web.1     |   severity: 'FATAL',
14:32:05 web.1     |   code: '28000',
14:32:05 web.1     |   detail: undefined,
14:32:05 web.1     |   hint: undefined,
14:32:05 web.1     |   position: undefined,
14:32:05 web.1     |   internalPosition: undefined,
14:32:05 web.1     |   internalQuery: undefined,
14:32:05 web.1     |   where: undefined,
14:32:05 web.1     |   file: 'auth.c',
14:32:05 web.1     |   line: '483',
14:32:05 web.1     |   routine: 'ClientAuthentication' }

这可能是 SSL 问题,但不应该像上面提到的那样here https://github.com/brianc/node-postgres/issues/25。 SSL 应该是开箱即用的支持。所以我很困惑,只能问什么可能导致这个错误?

我不确定是否需要编辑系统上的 pg_hba.conf,但我什至找不到它。


通过设置解决了PGSSLMODE (http://www.postgresql.org/docs/9.0/static/libpq-envars.html http://www.postgresql.org/docs/9.0/static/libpq-envars.html)在 Heroku 上。它告诉 PostgreSQL 默认使用 SSL。

$ heroku config:set PGSSLMODE=require
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

连接 Heroku PostgreSQL 数据库时出现身份验证错误 的相关文章

随机推荐