LightAtom

Port 5432: What It Is Used For (PostgreSQL)

Port 5432 is the default port of PostgreSQL database servers.

Mac developers often end up with two PostgreSQL servers fighting over 5432: Postgres.app and a Homebrew service, or a Docker container. Only one can listen; the other fails to start, or your app connects to the wrong one with the wrong data. lsof -nP -iTCP:5432 -sTCP:LISTEN shows which one owns the port.

Facts

Port
5432
Protocols
TCP
Service
PostgreSQL

What uses port 5432

PostgreSQL clients and tools (psql, pgAdmin, TablePlus, ORMs) connecting to the database.

On a Mac

On a Mac, 5432 usually belongs to Postgres.app, a Homebrew postgresql service or a Docker container. Two of them at once is a common cause of “address already in use”.

sudo lsof -nP -iTCP:5432

Security

Keep PostgreSQL on localhost or a private network and require passwords (scram-sha-256) in pg_hba.conf. Don't expose 5432 publicly.

Frequently asked questions

What uses port 5432?

PostgreSQL. On a Mac: Postgres.app, Homebrew's postgresql service or a Docker container.

Why does Postgres say port 5432 is in use?

Another PostgreSQL is already running. Find it with lsof -nP -iTCP:5432 -sTCP:LISTEN and stop it, or run the second one on 5433.

Why do I get ECONNREFUSED ::1:5432?

The client tried IPv6 localhost while Postgres listens on 127.0.0.1 only. Use 127.0.0.1 in the connection string or set listen_addresses to include ::1.

LightAtom team

The people who build LightAtom, a network monitor for macOS.