Port guide

PostgreSQL port 5432 on Windows — check, change & fix conflicts

PostgreSQL listens on port 5432 by default. This guide covers verifying the port is open, fixing port conflicts, changing the port in postgresql.conf and updating firewall rules.

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.

cmd.exe
# Verify PostgreSQL is listening on port 5432:
C:\> netstat -ano | findstr 5432
TCP 0.0.0.0:5432 0.0.0.0:0 LISTENING 3412
# Check which process owns port 5432:
C:\> tasklist | findstr 3412
postgres.exe 3412 Services 0 25,324 K

Fix "port 5432 already in use"

  • 1

    Find the process using port 5432

    cmd.exe
    C:\> netstat -ano | findstr :5432
    TCP 0.0.0.0:5432 0.0.0.0:0 LISTENING 8724
    # PID is 8724
    C:\> tasklist | findstr 8724
    postgres.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

    PowerShell — Administrator
    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

    cmd.exe — Administrator
    C:\> net stop postgresql-x64-18 && net start postgresql-x64-18
  • 3

    Verify new port

    cmd.exe
    C:\> netstat -ano | findstr 5433
    TCP 0.0.0.0:5433 0.0.0.0:0 LISTENING
    C:\> psql -U postgres -p 5433 -c "SELECT current_setting('port');"
    current_setting
    5433
  • 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?
No. Only one process can listen on a given port at a time. When you install a second PostgreSQL version, the installer assigns it a different port (e.g. 5433). You can configure them to use any ports you choose as long as they do not conflict.
Do I need to open port 5432 in Windows Firewall?
Only if you want connections from other machines. For local connections only (from the same PC), no firewall rule is needed. To allow remote connections, add an inbound rule for TCP port 5432. See Remote connections guide.
psql connects to the wrong PostgreSQL version
If you have multiple versions installed, always specify the port explicitly: psql -U postgres -p 5433 for the instance on port 5433. Or make sure the PATH points to the correct version bin directory first.

Need remote access?

Configure firewall and pg_hba.conf for connections from other machines.

Remote connections