Access remote Postgres server with pgAdmin

廉价感情. 提交于 2019-12-08 06:56:36

问题


I've got pgAdmin running on my XP machine. There's a Centos machine running a Postgres server on the network. The Postgres server pg_hba.conf file has the following lines

TYPE      DATABASE    USER      CIDR-ADDRESS       METHOD
host      all         all       10.0.0.68/32       trust
local     mydb        myuser                       password
local     all         postgres                     ident
host      mydb        myuser    10.0.0.68/32       password
host      all         postgres  10.0.0.68/32       trust

My postgresql.conf file has the following line:

listen_address = 'localhost, 10.0.20.10'

nmap -sS 10.0.20.10 shows:

PORT      STATE     SERVICE
5432/tcp  open      postgresql

I can ssh into a bash shell on the server, but I can't connect with pgAdmin. I get the following:

could not connect to server: No route to host(0x00002751/10065) Is the server running on host "10.0.20.10" and accepting TCP/IP connections on port 5432?

I've no idea what the problem is.


回答1:


@Aidan found the solution himself:

It was a firewall issue.

service iptables stop

enabled the connection. I'll just write a rule to allow the connection.




回答2:


Suppose server's IP address is 10.0.20.10 then you could just add these iptable rules as @Dark Star1 proposed in comments:

iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 10.0.20.10 --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 10.0.20.10 --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT


来源:https://stackoverflow.com/questions/7286264/access-remote-postgres-server-with-pgadmin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!