Database
Risk: High

Port 5432 β€” PostgreSQL Database

Port 5432 is the official IANA assigned port for the PostgreSQL relational database management system. PostgreSQL servers listen on this port for incoming SQL client connections.

PORT NUMBER

5432

PROTOCOL

TCP

DEFAULT PROCESS

postgres, pg_ctl

FIREWALL TARGET

5432/tcp

Instant Terminal Fixes for Port 5432

macOS & Linux Terminal
1. Check who is listening on port 5432:
sudo ss -tulpn | grep 5432 || pg_isready -p 5432
2. Kill process occupying port 5432 (EADDRINUSE fix):
sudo systemctl stop postgresql || sudo kill -9 $(sudo lsof -t -i:5432)
3. UFW Firewall Allow rule:
sudo ufw allow from 10.0.0.0/16 to any port 5432 proto tcp
Windows PowerShell (Admin)
1. Check listening port:
Get-NetTCPConnection -LocalPort 5432
2. Force kill process on port 5432:
Stop-Service postgresql* -Force
3. Docker Port Forwarding Mapping:
docker run -p 5432:5432 -e POSTGRES_PASSWORD=securepass -d postgres:16

Common Error Encountered

could not connect to server: Connection refused. Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?

Security Advisory & Hardening

Never bind PostgreSQL to 0.0.0.0 without strict pg_hba.conf IP whitelisting and SSL connection enforcement (ssl=on). Restrict access to localhost or your VPC subnet.

Frequently Asked Questions

Port 5432 Questions & Answers

Common questions regarding default services, kill commands, and firewall configurations.

Port 5432 is commonly used for PostgreSQL Database. Port 5432 is the official IANA assigned port for the PostgreSQL relational database management system. PostgreSQL servers listen on this port for incoming SQL client connections.