无法通过127.0.0.1连接到Postgresql

时间:2017-08-11 14:29:30

标签: postgresql database-connection

我尝试使用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连接。还有什么可以阻止连接?

1 个答案:

答案 0 :(得分:0)

不确定发生了什么,但我的笔记本电脑硬重启修复了这个问题。