WTF, Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Lately, I had this problem. Pretty annoying btw.
I was browsing internet and had several chrome tabs opened... Suddenly my mac crashed and frozen... I wait, but nothing happened, so I hard turned it off. The next day none of my rails applications were working.
I have postgres installed with brew. Started googling, and found this SO answer...
It basically says to remove the file
/usr/local/var/postgres/postmaster.pid
Basically since I shut my laptop down, postgres was not able of removing that file... on the next run postgres could not run.
Written by Miguel
Related protips
8 Responses
Removing that file worked for me. Thank you!
Thank you, that worked
Thanks, worked here :)
Im glad it is working for everyone! :D
Same here, thank you
Hello. I am having the same problem and it's driving me crazy. I searched in the folder /usr/local/var/postgres/postmaster and I don't have a postmaster.pid file. Any suggestions on what else I could try?
If you ran into this after upgrading with homebrew, you may need to follow the instructions here (instead of messing around with the postmaster.pid file): https://collectiveidea.com/blog/archives/2016/01/08/postgresql95-upgrade-with-homebrew
Those were written for version 9.5, but they worked perfectly for version 9.6.3 for me today.
This happens when postgres server is not running.
Steps to properly install Postgres via Homebrew on MAC :
brew install postgres
initdb /Users/<username>/db -E utf8
[This initializes postgres to use the given directory as the database directory. Normally it is not adviced to use the user directory for database storage. Edit sudoers file to add initdb and similar commands and then run initdb on /usr/local/var/postgres]pg_ctl -D /Users/<username>/db -l logfile start
[After getting success with step 2 it will prompt to run step 3. This command manually starts the server.]