gpt4 book ai didi

PostgreSQL:无法连接到服务器:端口 5432 上的 TCP/IP 连接

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

我在使用 PostgreSQL 时遇到错误:

SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

以下命令不显示 5432 端口已打开:

sudo netstat -plunt |grep postgres

我猜问题出在 5432 端口,因为我在 netstat 中没有看到它。
如何为 PostgreSQL 打开端口?

  1. postgresql.confpg_hba.conf 文件没问题(见下文)。
  2. postgres 服务器正在运行
  3. 我的 postgresql.conf 文件:
listen_addresses = '*'
port = 5432
  1. 我的 pg_hba.conf 文件:
local   all             postgres                                md5
local all all md5
host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
  1. 我运行了命令:$ netstat -atu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 localhost:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:https 0.0.0.0:* LISTEN
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11807 ESTABLISHED
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11258 ESTABLISHED
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11797 ESTABLISHED
tcp6 0 0 localhost:6379 [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:https [::]:* LISTEN
udp 0 0 localhost:domain 0.0.0.0:*
udp 0 0 30secondboomer.c:bootpc 0.0.0.0:*

最佳答案

设置时出现类似错误 PostgreSQL使用Python/Django项目。

  1. 尝试stoprestart再次打开服务器。
  2. 如果挑战确实是端口 5432如您所料,您可以尝试 start postgres在另一个端口上说 5433看看会发生什么。
  3. 对于那些database server根本没有运行,这个 solution阅读官方后为我工作PostgreSQL-9.6.16文档。

关于PostgreSQL:无法连接到服务器:端口 5432 上的 TCP/IP 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55326804/

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