这让我感到困惑。
我重新启动了ubuntu服务器,现在尝试与pgadmin连接,并得到以下信息:
could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "<ip.address>" and accepting
TCP/IP connections on port 5432?
在我的postgresql.conf文件中
listen_addresses = '*'
在我的pg_hba.conf中
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
host all all 129.125.179.201/32 trust
host all all 86.81.139.21/24 trust
我将以下行添加到末尾
host all all 0.0.0.0/0 md5
仍然无法连接
每次更改后,我都重新启动了postgresql。
我可以通过shh通过命令行登录到postgresql。
我没主意了!
编辑
iptables
sudo iptables -S
-P INPUT ACCEPT
-P FORWARD DROP
-P OUTPUT ACCEPT
-N DOCKER
-N DOCKER-ISOLATION
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j DROP
-A FORWARD -j DOCKER-ISOLATION
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -j DROP
-A OUTPUT -j ACCEPT
-A DOCKER-ISOLATION -j RETURN
Netstat结果
netstat -lt4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:mysql *:* LISTEN
tcp 0 0 *:8787 *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:postgresql *:* LISTEN
iptables保存
sudo iptables-save
# Generated by iptables-save v1.6.0 on Sat Sep 23 18:23:36 2017
*nat
:PREROUTING ACCEPT [48958:12725477]
:INPUT ACCEPT [2847:159736]
:OUTPUT ACCEPT [70:6309]
:POSTROUTING ACCEPT [70:6309]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A DOCKER -i docker0 -j RETURN
COMMIT
# Completed on Sat Sep 23 18:23:36 2017
# Generated by iptables-save v1.6.0 on Sat Sep 23 18:23:36 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:DOCKER - [0:0]
:DOCKER-ISOLATION - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j DROP
-A FORWARD -j DOCKER-ISOLATION
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -j DROP
-A OUTPUT -j ACCEPT
-A DOCKER-ISOLATION -j RETURN
COMMIT
# Completed on Sat Sep 23 18:23:36 2017
1
您没有偶然运行的防火墙,对吗?
—
Vanessa Deagan
不是我设置的,但是您如何检查?正如我所说的,它在重新启动之前运行正常。尽管我确实做了apt-get install postgis *来安装脚本,但是我还是试图进行pg_pointclouds的安装。
—
Spatial Digger
sudo iptables -S
。如果要从同一台计算机进行连接,则可能还需要尝试host all all 127.0.0.1/32 md5
。
我已经添加了iptables的输出,机器正在工作,我正在使用腻子ssh进行连接。感谢您的协助。
—
Spatial Digger
主机所有127.0.0.1/32 md5已在本地连接下设置。
—
Spatial Digger