Postgres.app on macOS will not start a server on port 5432
Port 5432 is already in useShort answer
Postgres.app fails to start when something else already holds port 5432, when another server uses the same data directory, or when a crash left a stale postmaster.pid. Find what listens on the port, stop it or give the new server a different port, and read postgres-server.log in the data directory.
Fix it fast
1Find out which cause you have
Find which process is listening on port 5432.
lsof -nP -iTCP:5432 -sTCP:LISTEN2Match what you see, then jump to its fix
- 1
lsof lists a postgres process that is not the one Postgres.app is starting, for example from another Postgres.app server or a second PostgreSQL install.Another PostgreSQL server already uses the portFix - 2
lsof shows a postgres process owned by a different Mac user account.Another macOS user is running Postgres.appFix - 3
Postgres.app reports Could not delete stale postmaster.pid file after a crash or forced shutdown.A stale postmaster.pid is left in the data directoryFix - 4
The app only shows that the server did not start.The cause is not clear from the app windowFix
- 1
What does the error look like?
Port 5432 is already in useCould not delete stale postmaster.pid file
Cause 1 of 4
Another PostgreSQL server already uses the port
1Check
Postgres.app says this error usually means a PostgreSQL server is already running on your Mac. It can be a different server inside Postgres.app, or a separate installation.
lsof -nP -iTCP:5432 -sTCP:LISTEN2Fix
Stop that server, or change the port of the new one in the Database Settings of Postgres.app. Only one server can use each port.
# In Postgres.app: select the server, open Database Settings, set Port to 5433, then Start.3Verify
The server shows as running, and psql connects on the chosen port.
psql -p 5433 -c 'select 1'Confirmed by postgresapp.com
Cause 2 of 4
Another macOS user is running Postgres.app
1Check
The documentation notes that another user on the same Mac may already be running Postgres.app, and each port can be used once.
lsof -nP -iTCP:5432 -sTCP:LISTEN2Fix
Ask that user to stop their server, or give each user's server its own port.
# Postgres.app, Database Settings > Port: use a different port for each user.3Verify
Both servers start.
lsof -nP -iTCP -sTCP:LISTEN | grep postgresConfirmed by postgresapp.com
Cause 3 of 4
A stale postmaster.pid is left in the data directory
1Check
If PostgreSQL crashes, the file can hold an old pid that prevents starting. Postgres.app normally removes it itself and reports the error when it cannot.
ls "DATA DIRECTORY/postmaster.pid"2Fix
Make sure no postgres process uses that data directory, then delete postmaster.pid from the data directory and start again. The data directory path is shown in the server settings of the app.
rm "DATA DIRECTORY/postmaster.pid"3Verify
Start the server from the app.
psql -c 'select version()'Confirmed by postgresapp.com
Cause 4 of 4
The cause is not clear from the app window
1Check
Quit Postgres.app, start the server by hand with the same data directory and port to see the full error, and read postgres-server.log in the data directory.
/Applications/Postgres.app/Contents/Versions/latest/bin/postgres -D "DATA DIRECTORY" -p 5432
tail -n 50 "DATA DIRECTORY/postgres-server.log"2Fix
Fix what the printed message names, then start from the app again.
# replace DATA DIRECTORY with the path shown in Database Settings3Verify
The manual start no longer prints an error.
psql -c 'select 1'Confirmed by postgresapp.com
How do I stop it coming back?
- Run one PostgreSQL install per port on a Mac; pick distinct ports when you keep several.
- Quit servers from Postgres.app before shutting the Mac down or removing the app.
- Add the Postgres.app bin folder to your PATH so psql talks to the server you expect.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Databases
Cannot connect to PostgreSQL on port 5432 from another machine
FATAL: no pg_hba.conf entry for host "198.51.100.7", user "app", database "appdb"
Two settings guard remote access.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
asyncpg InterfaceError: another operation is in progress with SQLAlchemy
InterfaceError raised from a FastAPI endpoint that runs several queries at once
A single database connection can run one operation at a time.
4 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fix