【问题标题】:Can't connect to Postgres remotely due to "no pg_hba.conf entry for host"由于“主机没有 pg_hba.conf 条目”,无法远程连接到 Postgres
【发布时间】:2019-11-08 15:02:00
【问题描述】:

编辑:最初的问题是关于连接的。

感谢 cmets,通知我必须添加防火墙规则。我做到了:

sudo ufw allow 5432/tcp

现在我得到一个不同的错误FATAL: no pg_hba.conf entry for host "[my_ip]"

现在确定如果我允许该文件中的所有内容,为什么?


原文:

我在运行 ubuntu 18 的数字海洋水滴上设置了一个 postgresql 数据库。

我想在 PGAdmin 4 中连接到它。

我已经编辑了postgressql.conf:

listen_addresses = '*'

我已经编辑了pg_hba.conf:

host all all ::/0 md5

然后我跑了sudo service postgresql restart

在 PGAdmin 中,我仍然收到此错误:

Unable to connect to server:

could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "[redacted]" ([redacted]) and accepting
TCP/IP connections on port 5432?

conf 文件显示它是5432

【问题讨论】:

  • 数据库主机上是否有激活的防火墙?
  • 我不确定。我会努力解决的
  • @a_horse_with_no_name 当我执行 sudo ufw status verbose 时,它显示 22/tcp 和 80/tcp(以及 v6 部分),动作为 ALLOW IN。 5432应该在里面吗?
  • 你必须在你的ufw中打开5432。
  • 这不是编程问题。您可以在dba.stackexchange.com 询问并在那里解决。

标签: postgresql digital-ocean


【解决方案1】:

我把这个添加到pg_hca.conf 文件中:

host all all ::/0 md5

host all all 0.0.0.0/0 md5

我无法连接到 PGAdmin 4

【讨论】:

    猜你喜欢
    • 2020-07-29
    • 2019-04-28
    • 2020-05-19
    • 2010-11-27
    • 1970-01-01
    • 2011-09-03
    • 2021-06-04
    • 2013-08-06
    • 2015-10-18
    相关资源
    最近更新 更多