请在回覆之前阅读,因为它可能发生重复.我正在运行我的postmaster(postgres)服务器.看到下面的’sudo netstat -anp | grep 5432’输出?
原文链接:https://www.f2er.com/postgresql/192555.htmltcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 29606/postmaster unix 2 [ ACC ] STREAM LISTENING 1650581 29606/postmaster /var/run/postgresql/.s.PGsql.5432 unix 2 [ ACC ] STREAM LISTENING 1650582 29606/postmaster /tmp/.s.PGsql.5432
我可以使用localhost连接
psql -h localhost (OR 127.0.0.1) -d <DB> -U user -W
但是当我尝试使用tcp从其他主机连接时,通过指定
psql -h ip_add_postmaster -d <DB> -U user -W
它抛出:
psql: could not connect to server: Connection refused
Is the server running on host XXXXXX and accepting TCP/IP connections on port 5432?
这里有什么问题?
pg_hba.conf # 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
在postgresql.conf中,
listen_addresses = 'localhost,127.0.0.1,ip_add_postmaster' Note: ip_add_postmaster is same as my Elastic IP and not public DNS. If this information matters.
我在这里做错了什么?机器托管在Amazon EC2上,并打开端口5432.