Port 5432 / TCP
PostgreSQL
Port 5432 – PostgreSQL Protocol Specification
Technical analysis, security advisories, vulnerability mitigation, and firewall syntax for TCP/UDP port 5432 (PostgreSQL).
Port Number
5432
Transport Protocol
TCP
Port Range Type
Registered (1024-49151)
Default Status
Restricted / LAN
Service Description & Architectural Context
Default database connection port for PostgreSQL object-relational database.
IANA / RFC Designation:
Port 5432 is assigned to PostgreSQL under the Internet Assigned Numbers Authority (IANA) service name registry. In enterprise infrastructure and homelab setups, services listening on this port must follow the principle of least privilege.
Security Analysis & Attack Surface Assessment
Configure pg_hba.conf to enforce scram-sha-256 password hashing and SSL.
Hardening Recommendations:
- Do not expose port 5432 to public WAN interfaces unless authenticated TLS or VPN wrapping is strictly enforced.
- Enforce rate-limiting using Fail2ban, CrowdSec, or cloud edge DDoS protection.
- Audit active listening sockets locally:
ss -tulpn | grep :5432ornetstat -ano | findstr :5432.
Firewall Rule Snippets for Port 5432
UFW (Ubuntu / Debian Linux)
sudo ufw allow 5432/tcp
iptables (Standard Linux Kernel)
sudo iptables -A INPUT -p tcp --dport 5432 -j ACCEPT
Windows PowerShell (Defender Advanced Firewall)
New-NetFirewallRule -DisplayName "Allow Port 5432" -Direction Inbound -LocalPort 5432 -Protocol TCP -Action Allow