我试图连接postgresql但我收到此错误.
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Run Code Online (Sandbox Code Playgroud)
我的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
Run Code Online (Sandbox Code Playgroud)
如果有人愿意解释这里有什么问题,我将非常感激,我该如何纠正它.
Cra*_*ger 103
你引用的错误与此无关pg_hba.conf; 它没有连接,没有授权连接.
执行错误消息所说的内容:
检查主机名和端口是否正确以及postmaster是否接受TCP/IP连接
您尚未显示产生错误的命令.假设您在localhost端口上连接5432(标准PostgreSQL安装的默认设置),则:
PostgreSQL没有运行
PostgreSQL没有监听TCP/IP连接(listen_addressesin postgresql.conf)
PostgreSQL只监听IPv4(0.0.0.0或127.0.0.1),你在IPv6(::1)上连接,反之亦然.这似乎是一些旧的Mac OS X版本的问题,这些版本具有奇怪的IPv6套接字行为,并且在一些较旧的Windows版本上.
PostgreSQL正在侦听与您连接的端口不同的端口
(不太可能)有iptables阻止环回连接的规则
(如果你没有连接localhost,它也可能是阻止TCP/IP连接的网络防火墙,但我猜你正在使用默认值,因为你没有说).
所以......检查一下:
ps -f -u postgres应列出postgres流程
sudo lsof -n -u postgres |grep LISTEN或者sudo netstat -ltnp | grep postgres应该显示PostgreSQL正在监听的TCP/IP地址和端口
顺便说一句,我想你一定是旧版本.在我的9.3安装中,错误更加详细:
$ psql -h localhost -p 12345
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 12345?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
210616 次 |
| 最近记录: |