在postgresql.conf中设置什么值来启用"localhost"和"127.0.0.1"以及ip地址?

dot*_*dot 7 postgresql

为了能够从另一台机器连接到我的postgresql数据库,我必须配置我的postgresql.conf文件,如下所示:

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '10.14.4.4'                # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 5432                             # (change requires restart)
Run Code Online (Sandbox Code Playgroud)

我尝试使用127.0.0.1但是没有用.也没有"localhost".我能做的唯一方法就是使用服务器的实际IP地址.我检查以确保在我的"主机"文件中,localhost被定义....

无论如何,我现在可以通过执行以下操作从不同的服务器进行连接:

psql -U test test -h 10.14.4.4
Run Code Online (Sandbox Code Playgroud)

但现在我注意到我无法使用以下语法在本地登录:

psql -U test test -h 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

在本地登录的唯一方法是

psql -U test test
Run Code Online (Sandbox Code Playgroud)

我试图将我的postgresql.conf文件更改为使用"*"...然后让我远程登录,但在本地,我仍然无法使用127.0.0.1或"localhost"进行连接.

如何设置它以便我的远程登录和本地登录都能正常工作?

谢谢.

编辑1

这是我的pg_hba.conf文件的样子:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                trust
#host    replication     postgres        127.0.0.1/32            trust
#host    replication     postgres        ::1/128                 trust
host    all             all             10.14.4.0/24 trust
host    replication     postgres        10.14.0.0/16              trust
Run Code Online (Sandbox Code Playgroud)