PortChecker Logo
PortChecker

Port 5432 — PostgreSQL (TCP)

PostgreSQL

What is Port 5432?

Baza danych PostgreSQL

This is a registered port (1024–49151) often assigned to vendor or application services like PostgreSQL.  ·  No formal RFC; PostgreSQL Frontend/Backend Protocol v3

When do you need Port 5432 open?

Open only when a remote application server must connect to PostgreSQL. For single-server setups, bind PostgreSQL to 127.0.0.1 and keep the port closed externally.

Common uses and software

  • PostgreSQL Server
  • pgAdmin
  • PostGIS
  • Supabase
  • TimescaleDB
  • Amazon RDS PostgreSQL
  • ElephantSQL

Security

Set listen_addresses = 'localhost' in postgresql.conf unless remote access is required. Configure pg_hba.conf to restrict connections to specific IPs with scram-sha-256 authentication. For remote access, use an SSH tunnel: ssh -L 5432:localhost:5432 user@server. Enable TLS for any remote connection. Regularly audit user privileges and rotate database passwords.

Is Port 5432 safe?

An open port increases your attack surface. Safety depends on how PostgreSQL is configured.

Medium risk

Keep PostgreSQL up to date with security patches. Require strong authentication and restrict access to the minimum necessary IP addresses.

Check Port 5432 now

Test connectivity for Port 5432 on any host.

1-65535

How to Open Port 5432

To allow incoming connections to Port 5432 (PostgreSQL) from outside your network, configure your firewall and add a port forwarding rule on your router pointing to your device's local IP address.

Windows Firewall

Open Windows Defender Firewall → Advanced Settings → Inbound Rules → New Rule → Port → TCP → Specific local ports: 5432 → Allow the connection → Name and save the rule.

netsh advfirewall firewall add rule name="Open Port 5432" dir=in action=allow protocol=tcp localport=5432
Linux (UFW / iptables)sudo ufw allow 5432/tcpsudo iptables -A INPUT -p tcp --dport 5432 -j ACCEPT
Router

Log into your router (192.168.1.1 or 192.168.0.1) → Port Forwarding → Add a new rule: Protocol TCP, External port 5432, Internal IP: your device's local IP, Internal port 5432 → Save.

How to close Port 5432

If you do not need PostgreSQL, block this port in your firewall or router.

Windows Firewall

To block port 5432 on Windows, run the following command in PowerShell or Command Prompt (as Administrator):

netsh advfirewall firewall add rule name="Block Port 5432" dir=in action=block protocol=tcp localport=5432
Linux (UFW / iptables)sudo ufw deny 5432/tcpsudo iptables -A INPUT -p tcp --dport 5432 -j DROP
Router

Remove or disable any port forwarding rule for Port 5432.

Frequently Asked Questions

What is Port 5432 used for?▾

Port 5432 is the default TCP port for PostgreSQL. It is used by servers and applications that need to accept incoming connections for this service. Whether you need it open depends on whether you are actively running a PostgreSQL server — if not, it should remain closed to reduce your attack surface.

Is Port 5432 safe to keep open?▾

An open Port 5432 increases your attack surface. If you are not actively running PostgreSQL, close this port in your firewall and remove any port forwarding rules. If PostgreSQL must be accessible, restrict access to known IP ranges, keep the service software updated with security patches, and use strong authentication.