My Macbook has OSX Mavericks installed and sometimes it crashes for no reason, breaking my local postgres server.
After restarting and running again "$ brew services postgres"
, Postgres becomes yellow and I end up spending sometime looking confused and frustrated.
Looking at the logs you can get a sense of whats happening:
|
|
Simply removing the lock file that Postgres generates solves this issue:
|
|
If you can’t find your
postmaster.pid
, just run the following snippet on your terminal:
$ find ~ -name postmaster.pid\*
Now a simple restart puts the server back online!
|
|
Why do we need to do this?
If your computer crashes and Postgres it's abruptly stopped, its cleanup procedures don’t run so the postmaster.pid
file is kept intact on your local hard drive.
Also, whenever we start postgres (pg_ctl start
) the program checks if there is an already running server by looking for an existing postmaster.pid
.
You can read more about this issue on Postgres mailing list