TCP · Port 5432IANA Registered

Port 5432 — PostgreSQL

Default TCP listening port for PostgreSQL object-relational database client connections.

⚡ Primary Use Cases & Environments

  • ✓Backend web applications (Django, Ruby on Rails, FastAPI) connecting to Postgres
  • ✓Data analytics tools and pgAdmin

🛡️ Security & Vulnerability Analysis

Ensure "listen_addresses = 'localhost'" in postgresql.conf unless remote access is specifically required. Restrict client IP ranges using pg_hba.conf and require scram-sha-256 password encryption.

🔧 Network Diagnostics & Inspection

1. Check Active Listening Sockets (Local Host)
Terminal Command
$ sudo ss -tuln | grep :5432
Inspects whether any local process daemon is bound to port 5432.
2. Remote Port & Service Scan (Nmap)
Terminal Command
$ nmap -p 5432 -sV <target-ip>
Probes target IP to determine whether port 5432 is open, closed, or filtered.
3. Wireshark Capture / Display Filter
pgsql or tcp.port == 5432Wireshark Filter

🔥 Firewall Configuration Rules (UFW & iptables)

UFW (Uncomplicated Firewall)
Terminal Command
$ sudo ufw allow from <app-ip> to any port 5432 proto tcp
Applies a persistent Linux UFW firewall rule for port 5432.
iptables Command
Terminal Command
$ sudo iptables -A INPUT -p tcp -s <app-ip> --dport 5432 -j ACCEPT
Appends a direct netfilter kernel rule to the INPUT chain for port 5432.

❓ Frequently Asked Questions (FAQ)

How do I test remote PostgreSQL connection on port 5432?

Run "pg_isready -h <host> -p 5432" or connect via psql: "psql -h <host> -p 5432 -U <user> -d <dbname>".

How do I configure PostgreSQL to accept connections only over SSL?

Set "ssl = on" in postgresql.conf and specify "hostssl" instead of "host" in your pg_hba.conf configuration file.

Related Networking Tools & Guides