when postgresql server didn't shut down cleanly, it often leaves a stale postmaster.pid
file behind — this file prevents postgresql from starting again
navigate to the postgresql data directory and delete the postmaster.pid
file:
rm /opt/homebrew/var/postgresql@15/postmaster.pid
⚠️ replace
15
with your actual postgresql version.
if you're not sure which version you're using, you can find the correct path using tab completion:
cd /opt/homebrew/var/
then press Tab
twice — it should show a directory like postgresql@14
, postgresql@15
, etc. and then go into that directory and delete the postmaster.pid
:
rm /opt/homebrew/var/postgresql@<your_version>/postmaster.pid
restart the postgresql service:
brew services restart postgresql@<your_version>