无法连接到 Heroku Postgres - 错误 "server closed the connection unexpectedly"
cannot connect to Heroku Postgres - error "server closed the connection unexpectedly"
我正在尝试使用 Heroku CLI 连接云中的 Postgres 数据库。
heroku pg:info
显示数据库信息,但 heroku pg:psql
失败并出现以下错误:
$ heroku pg:psql
--> Connecting to postgresql-<database-id>
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
怎么了?
必须解锁端口 5432 才能使 psql
正常工作,但我无法做到这一点。切换到不同的网络(例如家中的互联网提供商或移动互联网)可能会有所帮助。
可能不是每个人的问题,但如果您的计算机通过 ~/.postgresql/postgresql.crt
和 ~/.postgresql/postgresql.key
设置为 connect with mTLS,psql
将自动发送您连接到的所有数据库的密钥,您将中断 heroku pg:psql
与其他数据库的连接
就这样
mv ~/.postgresql{,.bak}
然后重试。如果那是你的问题,你需要将你的 mTLS 证书放在不同的目录中并手动传递它们 as arguments or via config vars
The location of the certificate and key files can be overridden by the
connection parameters sslcert and sslkey or the environment variables
PGSSLCERT and PGSSLKEY
我正在尝试使用 Heroku CLI 连接云中的 Postgres 数据库。
heroku pg:info
显示数据库信息,但 heroku pg:psql
失败并出现以下错误:
$ heroku pg:psql
--> Connecting to postgresql-<database-id>
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
怎么了?
必须解锁端口 5432 才能使 psql
正常工作,但我无法做到这一点。切换到不同的网络(例如家中的互联网提供商或移动互联网)可能会有所帮助。
可能不是每个人的问题,但如果您的计算机通过 ~/.postgresql/postgresql.crt
和 ~/.postgresql/postgresql.key
设置为 connect with mTLS,psql
将自动发送您连接到的所有数据库的密钥,您将中断 heroku pg:psql
与其他数据库的连接
就这样
mv ~/.postgresql{,.bak}
然后重试。如果那是你的问题,你需要将你的 mTLS 证书放在不同的目录中并手动传递它们 as arguments or via config vars
The location of the certificate and key files can be overridden by the connection parameters sslcert and sslkey or the environment variables PGSSLCERT and PGSSLKEY