Postgresql Centos问题

时间:2014-04-21 08:19:28

标签: postgresql centos postgresql-9.3

我正在尝试启用Postgresql 9.3以接受CentOS6上的远程连接。我在iptables中打开了端口,在pgconf文件中将端口设置为5432,将listen_addresses设置为'*'(接受所有连接),并允许pg_hba中的地址与主机全部为0.0.0.0/0信任。 postmaster在5432上运行。但是,我仍然收到以下错误。如何获得有效的连接?

错误:

could not connect to server: Connection refused
    Is the server running on host "50.63.141.236" and accepting
    TCP/IP connections on port 5432?

pg_hba.conf文件的相关部分:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
#opens postgres to the internet
host    all         all         0.0.0.0/0             trust

iptables -L的相关输出:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:postgres
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:postgres

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:postgres

最后,证明postmaster正在运行。

EN      1433/sshd
tcp        0      0 127.0.0.1:5432              0.0.0.0:*                   LIST   

1 个答案:

答案 0 :(得分:1)

更改listen_addresses后,您还没有重新启动PostgreSQL。它仍然在监听127.0.0.1,即仅限环回。或者您编辑了配置文件以进行不同的PostgreSQL安装。

如果您连接到主机127.0.0.1端口5432,它就可以正常运行。或者确保编辑了正确的配置并重启(而不仅仅是重新加载)PostgreSQL。