代码改变世界

postgresql远程连接不上

2022-05-09 20:58  abce  阅读(1908)  评论(0)    收藏  举报

postgresql远程连接不上

$ psql -h 33.33.33.33 -U postgres -d postgres -p 5432
psql: error: connection to server at "33.33.33.33", port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

  

问对方的listen_addresses是否做了修改,回复说已经设置成“*”了:

$ grep listen_addresses  postgresql.conf 
listen_addresses = '*'          # what IP address(es) to listen on;

  

让后让其远程登录,并查看一下listen_addresses的值:

$ psql
psql (14.2)
Type "help" for help.

postgres=# show listen_addresses;
 listen_addresses 
------------------
 localhost
(1 row)

postgres=#

  

可以看到虽然配置了listen_addresses ,但是并没有生效。

 

让其重启一下即可。