Port 5432

What’s running on port 5432 on my Mac?

5432 is PostgreSQL. On a developer Mac it’s common to have two of them, Homebrew and Postgres.app, or a native one and a Docker container, both wanting the same port.

Commonly used by

  • PostgreSQL (Homebrew)brew services start postgresql@17 runs postgres on localhost:5432.
  • Postgres.appMenu bar Postgres; servers use 5432 unless you change the port in Server Settings.
  • Docker postgres image-p 5432:5432 shows up as com.docker.backend (or OrbStack).
  • Supabase localUses 54322 for Postgres instead, so it doesn’t clash with your own.

Check what’s on port 5432

lsof -nP -iTCP:5432 -sTCP:LISTEN
ps -o pid,command -p <PID>
Path in the commandInstall
/opt/homebrew/opt/postgresql@17/bin/postgresHomebrew (brew services list)
/Applications/Postgres.app/...Postgres.app
com.docker.backend / OrbStackA container (docker ps --filter publish=5432)

You’ll see one postgres parent process plus several children; the parent holds the socket.

With Stat Space: statspace port 5432.

Fix “port 5432 already in use”

Decide which server you want, and stop the other one. Don’t kill -9 a database: use its own stop command so it shuts down cleanly.

brew services stop postgresql@17     # Homebrew
docker stop <container>              # Docker

For Postgres.app, click Stop in its window or menu bar icon. If you want both, move one of them:

  • Native: port = 5433 in postgresql.conf, then restart.
  • Docker: -p 127.0.0.1:5433:5432 (container side stays 5432).
  • Postgres.app: Server Settings › Port.

Security: keep it on localhost

PostgreSQL’s default is listen_addresses = 'localhost', and Homebrew keeps it. The usual way it ends up exposed is Docker:

# Listens on every interface of your Mac
docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres

# Listens only on this Mac
docker run -p 127.0.0.1:5432:5432 -e POSTGRES_PASSWORD=postgres postgres

A database on *:5432 with postgres/postgres credentials is an open door for anyone on the same Wi-Fi. Check with lsof: the NAME column should say 127.0.0.1:5432. If you set listen_addresses = '*' for a reason, also lock down pg_hba.conf. More in dev server exposed to the network.

Seeing it live

Stat Space lists 5432 as Postgres with its install path and warns if it’s bound to all interfaces. With Pro, a Docker-published Postgres shows its container and image instead of com.docker.backend.

Questions

How do I find which Postgres is on 5432?

Run lsof -nP -iTCP:5432 -sTCP:LISTEN, then ps -o command -p <PID>. A path under /opt/homebrew is Homebrew, /Applications/Postgres.app is Postgres.app, and com.docker.backend is a container.

How do I change PostgreSQL's port?

Set port = 5433 in postgresql.conf (find it with psql -c 'SHOW config_file') and restart the server. Connect with psql -p 5433.

Why can't my app connect even though Postgres is running?

You may be connecting to a different server than the one you think, for example Docker instead of Homebrew. The databases and users differ between them, so check which one owns the port.

Get started

Know what your Mac is doing, without adding to it.

Free, no account. Pro is $9.99 once for the first 100 buyers.