PostgreSQL无法(远程)连接到特定位置
我在我的机器上设置了一个数据库(使用PostgreSQL版本12),我试图在不使用“localhost”的情况下连接它 我对.conf文件进行了所有适当的更改,设置如下:PostgreSQL无法(远程)连接到特定位置,postgresql,server,remote-access,Postgresql,Server,Remote Access,我在我的机器上设置了一个数据库(使用PostgreSQL版本12),我试图在不使用“localhost”的情况下连接它 我对.conf文件进行了所有适当的更改,设置如下: Error: psql: could not connect to server: Connection refused Is the server running on host "192.168.0.1" and accepting TCP/IP connections on port 5432? 在
Error: psql: could not connect to server: Connection refused Is the server running on host "192.168.0.1" and accepting TCP/IP connections on port 5432?
在pg_hba.conf上:
# IPv4 local connections:
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
最后,关于postgresql.conf:
listen_addresses = '*' # what IP address(es) to listen on;
问题是,一旦我尝试使用以下命令从家连接数据库:
psql -h (myIPaddress) -p 5432 -U myUsername -d myDatabase
它工作得很好,但一旦我到了另一个地方(比如我朋友的房子),我就会出错,无法连接。显示的错误如下:
Error: psql: could not connect to server: Connection refused Is the server running on host "192.168.0.1" and accepting TCP/IP connections on port 5432?
为什么会发生这种情况?有人能帮我弄清楚吗
我会感谢你们的努力,如果你们需要的话,我会给你们更多的信息
非常感谢见