intro
Discover the PostgreSQL port configured by default (5432) and learn how to configure and change it.
Each database server runs a service that listens on a specific port by default. For example the PostgreSQL default port is 5432. In this guide, you’ll learn everything you need to know about the PostgreSQL port—what it is, why it matters, and how to change it if needed.
Let’s dive in!
What’s the PostgreSQL Default Port?
When setting up or connecting to a PostgreSQL database, you might wonder which network port it uses. The port is an address on the server that the database listens on for incoming connections. Knowing the correct port is fundamental for configuring connections, firewalls, etc.
Well, the default PostgreSQL port is 5432
. This is the port number PostgreSQL uses unless you or your package installer explicitly changed it.
Why 5432? No special reason beyond convention and registration. It’s just the assigned default.
For example, when connecting to PostgreSQL using a connection string or database client, you typically use the default port 5432
. Specifically, a default psql
connection URI might look like this:
1
psql postgresql://username@hostname:5432/database_name
Replace username
, hostname
, and database_name
with your actual PostgreSQL credentials and server details.
How to Check Which Port PostgreSQL Is Listening On
The easiest way to check which port a running PostgreSQL server is listening on is by running the following SQL command:
1
SHOW port;
As you can see by executing the query in a visual PostgreSQL database client like DbVisualizer, the output your PostgreSQL port number:

In this case, it is the PostgreSQL default port5432
.
An alternative approach is using the inet_server_port()
function:
1
SELECT inet_server_port();

This function returns the port number on which the PostgreSQL server accepted the current connection. Otherwise, it returns NULL
if the current connection is via a Unix-domain socket.
Checking the Postgres Port in Unix
To verify the port your PostgreSQL server is using on Unix-based systems like Linux or macOS, run the following command in the terminal:
1
sudo netstat -plnt | grep postgres
You’ll get output similar to this:
1
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1234/postgres
Where 5432
is the port PostgreSQL is listening on.
Checking the Postgres Port in Windows
To check which port PostgreSQL is using on Windows, run this command in Powershell:
1
tasklist | findstr postgres
Take note of the PID (Process ID) from the output, and use it to find the corresponding port:
1
netstat -ano | findstr POSTGRES_PID
The result will be something like:

Again, note that the PostgreSQL port is 5432
.
Notes about the PostgreSQL Port and How to Change It
Platform Specific Notes
Conclusion
In summary, 5432
is the default PostgreSQL port. If your Postgres isn’t reachable, double-check if it’s running on a non-standard port. Many client tools automatically use 5432
, so if you changed it, you’ll need to specify the new port. And if you run multiple Postgres servers, they each need their own port (5433
, 5434
, etc., as appropriate).
It’s usually a good idea to stick with 5432
unless you have a specific reason not to, as it’s the well-known port and makes setups predictable. If you do change it, document it to avoid confusion for anyone else connecting to the database.