1. What is Port 5432?
Port 5432 is the officially assigned IANA port for PostgreSQL, the world's most advanced open-source object-relational database management system. All PostgreSQL client libraries (pg in Node.js, asyncpg in Python, Npgsql in .NET, JDBC in Java) target port 5432 by default.
Port 5432 was registered with IANA in the 1990s by the PostgreSQL Global Development Group. It is within the user/registered port range (1024–49151).
2. How Port 5432 Works Under the Hood
Process creates a Winsock socket (`AF_INET`/`AF_INET6`, `SOCK_STREAM`) and binds to local port 5432.
Windows TCP/IP stack records the listening state in `MIB_TCPTABLE_OWNER_PID`.
Inbound HTTP/TCP traffic to `127.0.0.1:5432` is delivered directly through Windows loopback with zero physical NIC overhead.
The PostgreSQL engine (`postgres.exe`) starts a postmaster process that listens on TCP port 5432. 1. When a backend client initiates a connection, postmaster performs authentication (MD5/SCRAM-SHA-256) over TCP. 2. Once authenticated, postmaster forks or spawns a dedicated backend worker thread to handle all SQL queries over a binary stream protocol. 3. Connection poolers like PgBouncer often sit on 6432 or 5432 to multiplex thousands of client connections onto a small pool of database workers.
3. Common Conflicts & 'FATAL: lock file 'postmaster.pid' already exists / Error: bind: address already in use (5432)'
FATAL: lock file 'postmaster.pid' already exists / Error: bind: address already in use (5432)
The most notorious conflict on Windows happens when you install PostgreSQL directly via the Windows `.exe` installer (which installs a background Windows Service running 24/7) and later try to run a Docker Compose stack: ```text docker: Error response from daemon: driver failed programming external connectivity on endpoint my-postgres: Bind for 0.0.0.0:5432 failed: port is already allocated. ``` Stopping the background Windows service via `net stop postgresql-x64-16` or using PortPeek to inspect the process allows your container stack to start immediately.
4. How to Find & Stop the Process on Port 5432
If port 5432 is locked by an orphaned process or background service, choose one of the following methods:
PowerShell (Recommended):
Get-Process -Id (Get-NetTCPConnection -LocalPort 5432).OwningProcess | Stop-Process -Force
Classic CMD (Command Prompt):
for /f "tokens=5" %a in ('netstat -aon ^| findstr :5432') do taskkill /f /pid %a
Or simply use PortPeek
Never memorize netstat flags or parse PIDs again.
5. Standards & Related Ports
Official Specifications:
- IANA Service Name and Transport Protocol Port Number Registry
- RFC 6335, PostgreSQL Frontend/Backend Protocol 3.0
- Windows Sockets 2 (Winsock) API Documentation