Exported on 6/15/2025 at 18:07:29 GMT+9 from Cursor (1.1.2)
User
ugh my tests were hanging so i rebooted and now pg won't connect
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
this usually means there's a lockfile or postmaster pid or w/e the fuck stuck there. where is it (homebrew apple silicon)
Cursor
I'll help you fix this PostgreSQL connection issue. This is indeed typically caused by leftover lock files or PID files from an unclean shutdown. Let me check the status and find those files.
Perfect! I can see the issue. There's a postmaster.pid
file in the PostgreSQL data directory at /opt/homebrew/var/postgresql@16/postmaster.pid
. This is exactly what's preventing PostgreSQL from starting - it thinks another instance is already running.
Let me check what's in that PID file and then remove it:
Perfect! The issue is exactly what you suspected. There's a stale postmaster.pid
file from PID 787 (which is no longer running), and the file even shows "stopping" status. No PostgreSQL processes are actually running.
Let's clean this up:
Perfect! PostgreSQL is now running.
TL;DR: The issue was a stale postmaster.pid
file at /opt/homebrew/var/postgresql@16/postmaster.pid
. On homebrew Apple Silicon, PostgreSQL data lives in /opt/homebrew/var/postgresql@XX/
where XX is the version number.
The fix was:
- Remove the stale PID file:
rm /opt/homebrew/var/postgresql@16/postmaster.pid
- Restart the service:
brew services restart postgresql@16
For future reference, when PostgreSQL won't start after an unclean shutdown, check for these files in the data directory:
postmaster.pid
(the main culprit)postmaster.opts
(sometimes also needs cleanup)
Your PostgreSQL is now running and ready for your tests!