Postgres Is Now Running

Published September 20, 2017 | #postgres | ± 1 min

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:

$ tail -f /usr/local/var/postgres/server.log
FATAL:  lock file "" already exists

Simply removing the lock file that Postgres generates solves this issue:

$ rm -f /usr/local/var/postgres/

If you can’t find your, just run the following snippet on your terminal:

$ find ~ -name\*

Now a simple restart puts the server back online!

$ brew services start postgresql

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 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

You can read more about this issue on Postgres mailing list

comments powered by Disqus
Previous Post: ◀ 💰 Personal Finance
Next Post: ▶ SSH ForwardAgent Gotchas