psql不能连接到PostgreSQL服务器(postmaster)在IP和端口5432?

请在回覆之前阅读,因为它可能发生重复.我正在运行我的postmaster(postgres)服务器.看到下面的’sudo netstat -anp | grep 5432’输出
tcp  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.

当你的netstat输出显示为127.0.0.1:5432,这是localhost.这只能从localhost连接;)

在你的配置中设置listen_addresses =’*’,它将工作.

[编辑]
其他要检查的东西:

>亚马逊防火墙是否阻止任何东西?
iptables是否阻塞任何东西?

但首先要确保收听地址是正确的,你的netstat输出显示它不会这样工作.

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...