记PostgreSQL的连接问题

今天打开psql的时候出现这个错误

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?

解决如下

这个问题一般是以下原因造成的:

1.服务器没起来,ps -ef|grep postgres查看是否存在PG进程
2.监听问题,cat postgresql.conf|grep listen 查看监听地址端口是否正确
3.服务端超级用户能进去,其他用户不行,检查是否超出最大连接数限制
4.以上都没问题,服务器端能连进去,但客户端不行,这时需要查看pg_hba.conf文件
5.以上都没问题,检查服务器端的iptables,开启防火墙的访问端口

最后发现端口不是默认的5432,修改即可。

标签:PostgreSQL 发布于:2019-10-24 04:07:42