Skip to content
Look up and open a port

Port 5432: Use the PostgreSQL port securely

Port 5432 is the default port for PostgreSQL and uses TCP. This tool shows you the port details and generates firewall commands to restrict access to specific IP addresses.

Built by Justin Schuessler

Try the commands on your own VPS, with root access and your own firewall.

Add multiple ports one at a time, up to 12.

Or choose a preset

Ports

5432/TCPPostgreSQL

Databases · Registered port · OSI layer 7

Connections to PostgreSQL. If the application runs on the same server, the port does not need to be open.

IANA: officially registered as postgresql

Do not expose this port to the internet: Allow access only from a specific IP address, or connect via VPN or SSH tunnel.

Firewall rule (inbound)

At least one port should not be open to everyone. Choose “Specific IP” instead.

Firewall commands

Open port

sudo ufw allow 5432/tcp
Check port
Notes on ufw

For Ubuntu and Debian. ufw creates the rule for both IPv4 and IPv6. If ufw is disabled, allow SSH first (sudo ufw allow 22/tcp), then enable it with sudo ufw enable, or you'll lock yourself out.

On a ZAP-Hosting VPS with an active network firewall, you also need to allow the port in the Customer Panel.

Port 5432 explained

What is port 5432 used for?

Purpose

Applications, ORMs, and clients such as psql, pgAdmin, and DBeaver connect to a PostgreSQL server over port 5432. PostgreSQL is a widely used open-source database for web applications, backends, and data analysis. If the application runs on the same system, it usually connects locally via 127.0.0.1 or a Unix socket. You only need network access to port 5432 when the database and application run on separate servers or replicas need to connect.

Origin and standard

PostgreSQL originated from the POSTGRES research project at the University of California, Berkeley. After SQL was added as a query language, the project received its current name and has since been developed by an open community. IANA has assigned port 5432 to the “postgresql” service. It falls within the registered port range of 1024 to 49151.

Typical use

  • Database for web applications, APIs and backends
  • Connection from an app server to a separate database server
  • Streaming replication between primary and standby
  • Administration and queries with psql, pgAdmin, or DBeaver

Security

Port 5432 should never be open to the entire Internet: open database ports are continually scanned and targeted with password lists. By default, PostgreSQL listens only on localhost, as specified by listen_addresses in postgresql.conf. The pg_hba.conf also controls who can log in and from where; add only your app server's IP there, using a secure method such as scram-sha-256. Allow access to port 5432 only from that address in the firewall too. An SSH tunnel is the safer choice for administration from your own computer.

More ports

Related ports

These ports are often part of the same setup. Click one to see its explanation and firewall commands.

View all well-known ports and the complete IANA list

Port list source: IANA Service Name and Transport Protocol Port Number Registry, as of October 22, 2026. iana.org

Discover more

More tools

FAQ

Frequently asked questions

Quick answers about port 5432.

Only if an application on another server accesses PostgreSQL directly. If everything runs on one system, keep the port closed and connect locally. An SSH tunnel is a better option for administration from your PC.

With ufw, you can allow access specifically for your app server: sudo ufw allow from 203.0.113.10 to any port 5432 proto tcp. Add the same IP to pg_hba.conf and set listen_addresses to a reachable address. The connection will work only when all three settings are correct.

listen_addresses determines which network addresses PostgreSQL accepts connections on. The pg_hba.conf then determines which user can log in to which database, from which IP, and using which method. Both complement the firewall but do not replace it.

The connection reaches PostgreSQL, but there's no matching entry in pg_hba.conf for your combination of source IP, user and database. Add a line for that specific IP and reload the configuration. In this case, the firewall and port are already configured correctly.

Any more questions?

Contact Support
Your own server?

Try the commands on your own VPS

With a ZAP-Hosting VPS, you have root access, can set up services and firewall rules yourself, and can immediately see which ports are open.

4.4/5 Trustpilot32,000+ Active serversSince 2010

No setup. No risk. Online in seconds.

Flexible TermCancel anytimeOnline in 60 seconds

Looking for more tools? View all network tools