我尝试使用127.0.0.1
作为IP地址连接到Postgresql的本地实例,但始终拒绝连接:
⟩ 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 socket连接。还有什么可以阻止连接?
答案 0 :(得分:0)
不确定发生了什么,但我的笔记本电脑硬重启修复了这个问题。