Linux 无法连接到 PostgreSQL 服务器:无法连接到服务器:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8140863/
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
Unable to connect to PostgreSQL server: could not connect to server: Permission denied
提问by Manish
Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "10.0.1.201" and accepting TCP/IP connections on port 5432?
警告:pg_connect():无法连接到 PostgreSQL 服务器:无法连接到服务器:权限被拒绝 服务器是否在主机“10.0.1.201”上运行并接受端口 5432 上的 TCP/IP 连接?
This is the error i am getting when trying to connect to remote database from linux based server
这是我尝试从基于 linux 的服务器连接到远程数据库时遇到的错误
Though i am able to connect to it from localhost
虽然我可以从本地主机连接到它
Can anyone help me in this
谁能帮我这个
回答by igniter
In PostgreSQL you have to configure client authentication in pg_hba.confon the remote server.
在 PostgreSQL 中,您必须在远程服务器上的pg_hba.conf 中配置客户端身份验证。
Read more about pg_hba.conf @ http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html, otherwise you'll never connect to that server :).
阅读更多关于 pg_hba.conf @ http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html,否则你永远不会连接到该服务器:)。
Hope it will help, Stefan
希望它会有所帮助,斯蒂芬
回答by araqnid
Check the listen_addresses
setting in postgresql.conf
. If it is set to localhost
, then only loopback connections will be accepted, and remote connections will get a "connection refused" error. Set listen_addresses
to "*" to enable listening on all interfaces.
检查中的listen_addresses
设置postgresql.conf
。如果设置为localhost
,则只接受环回连接,远程连接将收到“连接被拒绝”错误。设置listen_addresses
为“*”以启用对所有接口的侦听。
回答by Amit Verma
One more possible scenario/solution that worked for me (for the very same problem) is here:
对我有用的另一种可能的方案/解决方案(针对同样的问题)在这里:
service httpd stop
service postgresql stop
setsebool -P httpd_can_network_connect 1
service httpd start
service postgresql start