【问题标题】:cannot connect to Heroku Postgres - error "server closed the connection unexpectedly"无法连接到 Heroku Postgres - 错误“服务器意外关闭连接”
【发布时间】:2018-01-11 00:02:37
【问题描述】:

我正在尝试使用 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.

怎么了?

【问题讨论】:

    标签: heroku-postgres heroku-cli


    【解决方案1】:

    可能不是每个人的问题,但如果您的计算机设置为connect with mTLS,通过~/.postgresql/postgresql.crt~/.postgresql/postgresql.keypsql 将自动将密钥发送到您连接到的所有数据库,你会中断heroku pg:psql 与其他数据库的连接

    就这样

    mv ~/.postgresql{,.bak}
    

    然后再试一次。如果这是您的问题,您需要将 mTLS 证书放在不同的目录中并手动传递它们as arguments or via config vars

    证书和密钥文件的位置可以被 连接参数 sslcert 和 sslkey 或环境变量 PGSSLCERT 和 PGSSLKEY

    【讨论】:

      【解决方案2】:

      必须解除对端口 5432 的阻塞,psql 才能工作,而我无法做到这一点。切换到其他网络(例如家庭互联网提供商或移动互联网)可能会有所帮助。

      【讨论】:

      • 切换到其他网络是什么意思?
      • @Shomaail 我更新了我的答案。据我记得,它在办公室不适合我,但在家里却很好。
      猜你喜欢
      • 1970-01-01
      • 2023-04-07
      • 2014-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      相关资源
      最近更新 更多