我努力连接到在Ubuntu 16.10上运行的远程Postgres 9.5实例。
通常:
psql:无法连接到服务器:连接超时
服务器是否在主机“xx.xx.xx.xx”上运行,并在端口5432上接受TCP / IP连接?
我的postgresql.conf包括
listen_addresses='*'
由输出确认
netstat -nlp | grep 5432 tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 22981/postgres tcp6 0 0 :::5432 :::* LISTEN 22981/postgres unix 2 [ ACC ] STREAM LISTENING 3320886 22981/postgres /var/run/postgresql/.s.PGSQL.5432
除了我的具体IP地址和范围外,我还尝试了pg_hba.conf中的以下条目:
host all all 0.0.0.0/0 md5 host all all ::/0 md5 host all all all md5 host all all * md5
我禁用了ufw并刷新了所有的iptables规则:
iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
用我的工作站nmap扫描:
nmap xx.xx.xx.xx -p5432 Starting Nmap 7.01 ( https://nmap.org ) at 2017-02-13 09:17 SAST Nmap scan report for xx.xx.xx.xx Host is up (0.0074s latency). PORT STATE SERVICE 5432/tcp filtered postgresql
telnet到xx.xx.xx.xx 5432超时。
SE几乎所有类似的问题似乎都可以通过解决
的listen_addresses = '*'
这在这里不是问题。
更改Postgres侦听的端口不起作用。
这是一个面向公众的networking接口的专用服务器。
服务器运行SSH和Nginx,两者都可以在界面上远程访问。
真的很困惑,帮助将不胜感激。
谢谢
编辑: tcpdump输出,同时尝试psql和telnet进入端口5432使用tcpdump开关build议在评论:
tcpdump -i enp2s0 -s0 -XX -vv -n "tcp port 5432" tcpdump: listening on enp2s0, link-type EN10MB (Ethernet), capture size 262144 bytes ^C 0 packets captured 2 packets received by filter 0 packets dropped by kernel
psql超时后Ctrl-C
原来,我的托pipe服务提供商将服务器移到托pipe防火墙后面,恕不另行通知