我正在尝试设置Postgres服务器,我需要它能够接受远程连接。
当我从客户端进行远程连接时,我总是出现这样的错误:
Connection to 192.168.1.6:5432 refused.
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP
我已经用下面的代码行编辑了文件pg_hba.conf
:
host all all 0.0.0.0/0 md5
和
host all all ::/0 md5
以便接受每个远程连接。
我还编辑了文件postgresql.conf
,将侦听地址设置为*
。
我该如何解决这个问题?
发布于 2015-06-29 17:28:18
通过ssh连接到您的服务器并发出命令netstat -tlpn | grep 5432
,您应该会得到类似的输出
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 31309/postmaster tcp 0 0 :::5432 :::* LISTEN 31309/postmaster
这意味着postgres已经准备好接受端口5432上的远程连接。否则需要重新勾选postgresql.conf中的listen参数,重启postgresql集群(不重装)。如果您仍然无法获得远程访问,请尝试暂时禁用服务器和客户端iptables -F
上防火墙
https://stackoverflow.com/questions/30962422
复制相似问题