在 linode vps 上开启了 postgres 5432 端口

lsof -i :5432
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postmaste 24734 postgres    3u  IPv4  53994      0t0  TCP *:postgres (LISTEN)
postmaste 24734 postgres    4u  IPv6  53995      0t0  TCP *:postgres (LISTEN)

但是通过本地无法连接,报 Connection refused

telnet x.x.x.x 5432
Trying x.x.x.x...
telnet: connect to address x.x.x.x: Connection refused
telnet: Unable to connect to remote host

最终搜索 解决办法(https://linuxconfig.org/redhat-8-open-and-close-ports)

# firewall-cmd --zone=public --permanent --add-port 5432/tcp
success

# firewall-cmd --reload
success

# lsof -i :5432
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postmaste 24734 postgres    3u  IPv4  53994      0t0  TCP *:postgres (LISTEN)
postmaste 24734 postgres    4u  IPv6  53995      0t0  TCP *:postgres (LISTEN)

本地继续telnet

~ telnet x.x.x.x 5432
Trying x.x.x.x...
Connected to li220-31.members.linode.com.
Escape character is '^]'.
^CConnection closed by foreign host.