2017-08-11 75 views
0

我试图用127.0.0.1作为IP地址连接到PostgreSQL的本地实例连接到PostgreSQL,但连接始终否认:无法通过127.0.0.1

⟩ psql -h 127.0.0.1 -U postgres -p 5432 
psql: could not connect to server: Connection refused 
    Is the server running on host "127.0.0.1" and accepting 
    TCP/IP connections on port 5432? 

pg_hba.conf看起来是这样的:

# TYPE DATABASE  USER   ADDRESS     METHOD 
# "local" is for Unix domain socket connections only 
local all    all          password 
# IPv4 local connections: 
host all    all    127.0.0.1/32   md5 
# IPv6 local connections: 
host all    all    ::1/128     trust 

postgresql.conf有如下条目:

listen_addresses = 'localhost, 127.0.0.1' 
port=5432 
unix_socket_directories = '/private/tmp' 

但是我可以通过unix插座进行连接。还有什么可以阻止连接?

+0

x发布为https://dba.stackexchange.com/q/183263/7788 –

+0

在unix套接字连接上运行'SHOW port; SHOW listen_addresses;'。有一个可以过滤连接的软件防火墙吗? –

回答

0

不知道发生了什么,但我的笔记本电脑硬重启解决了这个问题。