【问题标题】:psql: could not connect to server: No route to hostpsql:无法连接到服务器:没有到主机的路由
【发布时间】:2018-04-19 02:31:02
【问题描述】:

目前我无法从客户端连接到 PostgreSQL。客户端IP为“10.0.0.121”,我的服务器IP为“10.0.0.104”。

当我尝试与psql -U postgres -h 10.0.0.121 连接时,我收到以下错误:

psql: could not connect to server: No route to host
Is the server running on host "10.0.0.104" and accepting
TCP/IP connections on port 5432?

我已经配置了我的服务器:

pg_hba.conf

host    all             all             10.0.0.121/32           md5

postgresql.conf

listen_addresses = '*'          # what IP address(es) to listen on;
port = 5432

我还需要配置什么吗?

【问题讨论】:

  • 还要确保你重新加载了 pg_hba:select pg_reload_conf();
  • "No route to host" 表示 psql 甚至无法定位服务器。这可能是网络问题,而不是 Postgres 配置问题

标签: postgresql remote-access psql


【解决方案1】:

问题出在 pg_hba.conf 文件中,因为您使用的是 32 位掩码,如果您想获取一个段,则只能访问指定的 ip 10.0.0.120使用小于 32 位的掩码(例如 10.0.0.120/24),如果您想尝试使用包 nmap 列出相关 IP 10.0.0.121 公开的端口

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-06
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 2014-10-22
    • 2012-09-10
    • 1970-01-01
    相关资源
    最近更新 更多