我试图连接postgresql,但我收到这个错误。
org.postgresql.util.PsqlException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
我的pg_hba.conf文件是这样的。
TYPE DATABASE USER CIDR-ADDRESS METHOD# IPv4 local connections:host all all 127.0.0.1/32 md5# IPv6 local connections:host all all ::1/128 md5
如果有人请你好好解释这里有什么意见,我该如何纠正,我将是非常有责任感的。
你引用的错误与pg_hba.conf无关;它无法连接,而不是无法授权连接。做错误信息说:
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
您没有显示产生错误的命令。假设您在本地主机端口5432(标准Postgresql安装的默认值)上连接,则可以:
> Postgresql没有运行
> Postgresql没有监听TCP / IP连接(postgresql.conf中的Listen_addresses)
> Postgresql只侦听IPv4(0.0.0.0或127.0.0.1),你在IPv6(:: 1)上连接,反之亦然。这似乎是一些旧的Mac OS X版本,具有奇怪的IPv6套接字行为和一些较旧的windows版本上的问题。
> Postgresql正在侦听与您所连接的端口不同的端口
(不太可能)有一个iptables规则阻止环回连接
(如果您不在本地主机上连接,也可能是阻止TCP / IP连接的网络防火墙,但是我猜测您使用默认值,因为您没有说)。
所以检查那些:
> ps -f -u postgres应该列出postgres进程
> sudo lsof -n -u postgres | grep ListEN或sudo netstat -ltnp | grep postgres应该显示Postgresql正在侦听的TCP / IP地址和端口
BTW,我想你一定是旧版本。在我的9.3安装中,错误是比较详细的:
$ psql -h localhost -p 12345psql: Could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 12345?总结
以上是内存溢出为你收集整理的Postgresql:连接被拒绝 检查主机名和端口是否正确,并且postmaster正在接受TCP/IP连接全部内容,希望文章能够帮你解决Postgresql:连接被拒绝 检查主机名和端口是否正确,并且postmaster正在接受TCP/IP连接所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)