服务器是在主机"localhost"(:: 1)上运行并在端口5432上接受TCP/IP连接吗?

use*_*546 38 postgresql

我正在研究Django.我使用PostgreSQL数据库.

完整错误说:

could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)

你有什么主意吗?

Cra*_*ger 15

野生刺在黑暗中:你的机器上,其中一个IPv6解析器localhost默认使用IPv6地址::1,但是listen_addressespostgresql.conf设为127.0.0.10.0.0.0没有*,或者你使用的是与不具有透明IPv6的C库构建一个旧的PostgreSQL支持.

更改listen_addresseslocalhost并确保localhost解析为IPv4和IPv6地址,或将其设置为::1, 127.0.0.1显式指定IPv4和IPv6.或者只是将其设置*为侦听所有接口.或者,如果您不关心IPv6,请连接到127.0.0.1而不是localhost.

有关详细信息,请参阅此Google搜索此Stack Overflow搜索.

(尽管我的投票结果很紧,因为我投票支持移民问题).

  • 已经有一段时间了,但我遇到了同样的错误,并通过将 postgresql.conf 中的监听端口更改为 5432(原为 5433)来修复它,但是如果我想将 5433 保留在 conf 中怎么办? (2认同)