拒绝 PostgreSQL 连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42796434/
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
PostgreSQL Connection Refused
提问by dino9239
I have installed PostgreSQL. However everytime I try to connect through PGAdmin or through psql it gives me the below error.
我已经安装了 PostgreSQL。但是,每次我尝试通过 PGAdmin 或 psql 连接时,都会出现以下错误。
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?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?
I checked the postgresql.conf
file and the line: listen_addresses = '*'
isn't commented out.
我检查了postgresql.conf
文件和行:listen_addresses = '*'
没有被注释掉。
Also this is how my pg_hba.conf
file is set:
这也是我的pg_hba.conf
文件的设置方式:
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Can anyone please advise on how I can resolve this issue?
任何人都可以请教我如何解决这个问题?
Thanks!
谢谢!
回答by tayfun K?l??
Use services "start -> run -> services.msc" and look for the postgresql-[vers] service.
使用服务“开始 -> 运行 -> services.msc”并查找 postgresql-[vers] 服务。
If it is not running try to start it, if it won't start open the event-viewer (start -> run -> eventvwr) and look for error messages relating to the PostgreSQL service.
如果它没有运行,请尝试启动它,如果它不会启动,请打开事件查看器(开始 -> 运行 -> eventvwr)并查找与 PostgreSQL 服务相关的错误消息。
回答by Yan LimaBenua
Maybe u can try this .. open cmd and insert..
也许你可以试试这个..打开cmd并插入..
"C:\Program Files\PostgreSQL\bin\pg_ctl.exe" runservice -N "postgresql-x64-11" -D "C:\Program Files\PostgreSQL\data" -w
hit enter... :)
按回车... :)
回答by MwamiTovi
My pg_hba.conf
and postgresql.conf
files are on point.
And if the earlier answers haven't worked for you, like me.
我的pg_hba.conf
和postgresql.conf
文件都在点上。
如果之前的答案对你不起作用,就像我一样。
Here is a solution.
I figured this out after reading through the official PostrgeSQL-9.6.16
documentation.
这是一个解决方案。
我在阅读官方PostrgeSQL-9.6.16
文档后发现了这一点。
回答by Kairat Koibagarov
It works for me. Remember, whatever comes after -D should be the path to where you installed PostgreSQL, to the data folder, which holds the pg_hba.conf and postgresql.conf files.
这个对我有用。请记住,-D 之后的任何内容都应该是您安装 PostgreSQL 的路径、数据文件夹的路径,该文件夹包含 pg_hba.conf 和 postgresql.conf 文件。
pg_ctl start -D "C:/Program Files/PostgreSQL/9.6/data"
回答by Gab
pg_hba.conf.txt
has to be called pg_hba.conf
.
pg_hba.conf.txt
必须被调用pg_hba.conf
。
Beyond this, when you have en authentication error you will get a message similar to:
除此之外,当您遇到身份验证错误时,您将收到类似于以下内容的消息:
psql -U nonexistent
psql: FATAL: Peer authentication failed for user "nonexistent"
The error you are getting means most likely that PostgreSQL is not started on this server.
您收到的错误很可能意味着 PostgreSQL 未在此服务器上启动。
You can start PostgreSQL with:
您可以使用以下命令启动 PostgreSQL:
service postgresql start
service postgresql status
回答by Karthik Sagar
This worked for me -
这对我有用-
In C:\Program Files\PostgreSQL\data\postgresql.conf set listen_addresses ='localhost'
Then try -
然后试试——
pg_ctl -D "C:\Program Files\PostgreSQL.5\data" start
if already try restarting using pg_ctl
如果已经尝试使用 pg_ctl 重新启动