Free tech learning for everyone, from basics to pro

Port 5432: PostgreSQL (PostgreSQL database)

What port 5432 (TCP) does, the security risks of leaving it open, and how to secure and test it.

Port5432
TransportTCP
ServicePostgreSQL database (PostgreSQL)
EncryptedOptional (TLS)

What is port 5432?

TCP 5432 is the default port for PostgreSQL databases.

Common uses

  • Applications and analytics tools connecting to PostgreSQL

Security risks

  • Internet-exposed databases attacked with password guessing
  • Over-permissive pg_hba.conf rules allowing anyone to connect

How to secure port 5432

  • Listen only on private addresses
  • Restrict access in pg_hba.conf and require scram-sha-256 passwords
  • Require TLS for remote connections

How to check if port 5432 is open

WhereCommand
Scan from another machinenmap -p 5432 <host>
Windows (PowerShell)Test-NetConnection <host> -Port 5432
Linux (what is listening)sudo ss -tulpn | grep :5432
Windows (what is listening)netstat -ano | findstr :5432

Only scan systems you own or have permission to test.

Example: block it at the internet edge (Cisco)

For a service that should stay inside your network, deny it on the internet-facing interface. Put the rule before any broader permit statements:

ip access-list extended INTERNET-IN
 remark Block PostgreSQL from the internet
 deny   tcp any any eq 5432
 permit ip any any
!
interface GigabitEthernet0/0
 ip access-group INTERNET-IN in

In a real network the final line would be your normal inbound policy, not "permit ip any any". Build and check rules with the ACL builder.

Related ports

Frequently asked questions

What is port 5432 used for?

Port 5432 (TCP) is used by PostgreSQL database (PostgreSQL). TCP 5432 is the default port for PostgreSQL databases.

Is it safe to open port 5432?

Only if the service needs to be reached and is configured securely. Listen only on private addresses.

How do I check if port 5432 is open?

From another computer, run nmap -p 5432 followed by the host address. On the server itself, ss -tulpn on Linux or netstat -ano on Windows shows whether anything is listening on 5432.

Learn more: TCP, UDP and ports explained and firewall basics.

Get free updates by email

New notes, tools, CCNA and Security+ tips and important security news from FM TecHub, explained simply. Free, about twice a month. Unsubscribe anytime; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesup

Free · no spam · past emails · powered by Buttondown