gpt4 book ai didi

postgresql - 不允许在 Postgres 中进行外部连接

转载 作者:行者123 更新时间:2023-11-29 13:45:13 26 4
gpt4 key购买 nike

我有一台安装了 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我还应该做什么?

最佳答案

  • 使用

    netstat -an | grep 5432

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

  • 查看 postgresql.conf 中设置的 port

  • 在 PostgreSQL 服务器进程上使用 lsof 查看 PostgreSQL 正在监听哪些套接字。

关于postgresql - 不允许在 Postgres 中进行外部连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49498561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com