Postgresql Centos 问题

标签 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   

最佳答案

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

如果您连接到主机 127.0.0.1端口 5432它会工作的。或者确保您编辑了正确的配置并重新启动(不仅仅是重新加载)PostgreSQL。

关于Postgresql Centos 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23193580/

相关文章:

postgresql - 从函数执行字符串查询

macos - 在 Mac OS Yosemite 中尝试 "pip install psycopg2"时出现错误代码 1

linux - 同一服务器上的两个不同项目(不同的index.php)

java - 如何从java维护Postgres中表数据的版本

django - 在 PostgreSQL(PostGIS) 中优化 ST_Intersects

postgresql - 测试 Postgres json 数组中的项目成员资格

sql - 从 TimescaleDB 获取 1 年的结果

postgresql - 我应该如何提取 Postgres 函数中的重复逻辑?

java - 找不到类名 : com. mysql.jdbc.Driver 的驱动程序

centos - 是否允许同步和分发特定的软件集合存储库?