PostgreSQL uses port 5432 by default
PostgreSQL listens on TCP port 5432 by default. This is the registered IANA port for PostgreSQL. All clients — psql, pgAdmin, ODBC drivers, application frameworks — connect to this port by default unless configured otherwise.
Fix "port 5432 already in use"
- 1
Find the process using port 5432
C:\> netstat -ano | findstr :5432TCP 0.0.0.0:5432 0.0.0.0:0 LISTENING 8724# PID is 8724C:\> tasklist | findstr 8724postgres.exe 8724 ... - 2
If it is another PostgreSQL instance
You may have two PostgreSQL versions installed. Stop the other instance via services.msc or
net stop postgresql-x64-16(for version 16). Then start your intended version. - 3
If it is a different application
Either stop the conflicting application, or change the PostgreSQL port as described below.
How to change PostgreSQL port on Windows
- 1
Edit postgresql.conf
PS> notepad "C:\Program Files\PostgreSQL\18\data\postgresql.conf"# Find the line: #port = 5432# Uncomment and change to your desired port:port = 5433 - 2
Restart the service
C:\> net stop postgresql-x64-18 && net start postgresql-x64-18 - 3
Verify new port
C:\> netstat -ano | findstr 5433TCP 0.0.0.0:5433 0.0.0.0:0 LISTENINGC:\> psql -U postgres -p 5433 -c "SELECT current_setting('port');"current_setting5433 - 4
Update Windows Firewall rule
If you have a firewall rule for port 5432, add a new rule for the new port or update the existing one. See Remote connections guide.
Port 5432 questions
Can two PostgreSQL versions use the same port?
Do I need to open port 5432 in Windows Firewall?
psql connects to the wrong PostgreSQL version
psql -U postgres -p 5433 for the instance on port 5433. Or make sure the PATH points to the correct version bin directory first.