SoFunction
Updated on 2025-04-08

How to view postgres database port

As shown below:

Linux:

netstat -a | grep PGSQL

Sample output:

[highgo@hgdbt data]$ netstat -a | grep PGSQL
unix 2  [ ACC ]  STREAM  LISTENING  14710 /tmp/..5866

Supplement: The issue of postgresql port not being opened to the public

Suddenly I encountered a problem. The server's postgresql cannot be connected. I scanned the following 5432 port and did not open it.

However, on the server, netstats ps -e|grep 5432 nmap iptables and other commands are displayed open

Just can't scan outside

Googled, the solution is as follows

vim /etc/postgresql/(Version number)/main/

Modify listen_addresses to the IP address of the external interface

Restart pgsql, ok

The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.