postgresql 服务器是否在主机“localhost”(::1) 上运行并接受端口 5432 上的 TCP/IP 连接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17648677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
提问by user2582546
I'm working on Django. I use PostgreSQL database.
我正在研究 Django。我使用 PostgreSQL 数据库。
Full error says:
完整错误说:
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?
Do you have any idea?
你有什么主意吗?
回答by Craig Ringer
Wild stab in the dark: You're on a machine with an IPv6 resolver where localhost
defaults to the IPv6 address ::1
, but listen_addresses
in postgresql.conf
is set to 127.0.0.1
or 0.0.0.0
not *
or you're using an older PostgreSQL built with a C library that doesn't have transparent IPv6 support.
野生刺在黑暗中:你的机器上,其中一个IPv6解析器localhost
默认使用IPv6地址::1
,但是listen_addresses
在postgresql.conf
设为127.0.0.1
或0.0.0.0
没有*
,或者你使用的是老式的PostgreSQL建与不具有透明IPv6的C库支持。
Change listen_addresses
to localhost
and make sure localhost
resolves to both the IPv4 and IPv6 addresses, or set it to ::1, 127.0.0.1
to explicitly specify both IPv4 and IPv6. Or just set it to *
to listen on all interfaces. Alternately, if you don't care about IPv6, connect to 127.0.0.1
instead of localhost
.
更改listen_addresses
为localhost
并确保localhost
解析为 IPv4 和 IPv6 地址,或将其设置::1, 127.0.0.1
为显式指定 IPv4 和 IPv6。或者只是将其设置*
为侦听所有接口。或者,如果您不关心 IPv6,请连接到127.0.0.1
而不是localhost
.
See this Google searchor this Stack Overflow searchfor more information.
请参阅此 Google 搜索或此 Stack Overflow 搜索以获取更多信息。
(Posting despite my close-vote because I voted the question for migration).
(尽管我投票接近,但还是发布了,因为我投票支持移民问题)。