Skip to content

Instantly share code, notes, and snippets.

@pcreux
Created May 1, 2014 22:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcreux/8034ddcbf91882a6bfb8 to your computer and use it in GitHub Desktop.
Save pcreux/8034ddcbf91882a6bfb8 to your computer and use it in GitHub Desktop.
Repair postgres (homebrew) after a system crash

When my mac crashes and Postgres doesn't boot properly I see the following errors in /usr/local/var/postgres/server.log

FATAL:  lock file "postmaster.pid" already exists

# and / or

lock file "/var/pgsql_socket/.s.PGSQL.5432.lock" already exists

Here are the commands to put Postgres back on track:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm /var/pgsql_socket/.s.PGSQL.5432.lock
rm /usr/local/var/postgres/postmaster.pid
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment