【问题标题】:Cannot allow external connections in Postgres不允许 Postgres 中的外部连接
【发布时间】:2018-09-05 00:24:29
【问题描述】:

我有一台安装了 Postgres 的服务器,我想允许来自外部 IP 的连接。 Postgres 非常适合本地连接,然后在文件末尾/var/lib/pgsql/data/postgressql.conf 我添加了:

listen_addresses = '*'

/var/pgsql/data/pg_hba.conf的末尾我补充说:

host    all             all              0.0.0.0/0                md5
host    all             all              ::/0                     md5

然后我重新启动了 postgres:sudo systemctl restart postgresql 并尝试联系:psql -h my.db.server.ip -U postgres

我得到:

psql: could not connect to server: No existe ninguna ruta hasta el «host»
    Is the server running on host "my.db.server.ip  and accepting
    TCP/IP connections on port 5432?

我正在使用 Centos 7 和 PostgreSQL 9.2.23 我还应该做什么?

【问题讨论】:

    标签: postgresql centos centos7


    【解决方案1】:
    • 使用

      netstat -an | grep 5432
      

      在服务器上查看是否有任何东西正在监听端口 5432。

    • 查看portpostgresql.conf 中的设置。

    • 在 PostgreSQL 服务器进程上使用 lsof 来查看 PostgreSQL 正在侦听的套接字。

    【讨论】:

    • 您好!是的,确实它正在运行,问题是防火墙。我打开了端口,终于成功了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-24
    • 2018-11-07
    • 2020-05-27
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多