我正在使用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?
你有什么想法吗?
我正在使用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?
你有什么想法吗?
猜测可能是因为您所在的机器具有IPv6解析器,其中localhost
默认为IPv6地址::1
,但postgresql.conf
中的listen_addresses
设置为127.0.0.1
或0.0.0.0
而不是*
,或者您正在使用一个构建于没有透明IPv6支持的C库中的旧版PostgreSQL。
将listen_addresses
更改为localhost
并确保localhost
解析为IPv4和IPv6地址,或将其设置为::1, 127.0.0.1
以显式指定IPv4和IPv6。或者只需将其设置为*
以监听所有接口。或者,如果您不关心IPv6,请连接到127.0.0.1
而不是localhost
。
有关更多信息,请参见此Google搜索或此Stack Overflow搜索。
(尽管我投票将问题迁移,但仍然发表回答)