【问题标题】:Unable to establish a psql session with remote heroku database无法与远程 heroku 数据库建立 psql 会话
【发布时间】:2019-11-05 02:23:33
【问题描述】:

我有一个远程 heroku 数据库(“爱好”层)并想建立一个远程 psql 连接,但是当我键入时:

heroku pg:psql

我收到以下错误:

psql: could not connect to server: Operation timed out
    Is the server running on host "ec2-54-163-230-199.compute-1.amazonaws.com" (54.163.230.199) and accepting
    TCP/IP connections on port 5432?

我已经编辑了 postgresql.conf 这样

listen_addresses = '*'

并添加了一行:

host all all 0.0.0.0/0 md5

到 pg_hba.conf,因为我认为问题可能是我的 postgres 配置只接受到 localhost 的连接,但重新启动 Postgres 我仍然遇到同样的错误。

有人对可能出现的问题有任何建议吗?如果我的防火墙被阻止,有人会对如何改变它有任何建议吗?提前致谢。

【问题讨论】:

  • “我已经编辑了 postgresql.conf 这样......”——你会在哪里做这个?我相当肯定 Heroku 没有提供 Postgres 配置文件供您编辑。 “并添加...到 pg_hba.conf”——它当然没有提供您可以修改的 pg_hba.conf
  • 感谢您的回复。我在本地安装的 Postgres (Postgres.app) 的数据目录中编辑了 postgresql.conf 和 pg_hba.conf,因为我认为可能是我的本地 Postgres 配置阻止了连接的建立。
  • 这些文件对heroku pg:psql 没有任何影响。您是否在限制性防火墙后面?您的应用程序是否成功连接到您的数据库?
  • 非常感谢您,我尝试更改我的互联网连接以使用我手机的热点并且连接成功,因此这一定是您建议的限制性防火墙的问题 - 再次感谢!

标签: postgresql heroku heroku-postgres heroku-cli


【解决方案1】:

必须有网络限制或防火墙设置,因为它应该可以在不更改 conf 文件的情况下工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-20
    • 1970-01-01
    • 2022-01-12
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-02
    相关资源
    最近更新 更多