Last Updated: January 04, 2018
·
54.53K
· miguelperez

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

http://stackoverflow.com/questions/13573204/psql-could-not-connect-to-server-no-such-file-or-directory-mac-os-x

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.

8 Responses
Add your response

Removing that file worked for me. Thank you!

over 1 year ago ·

Thank you, that worked

over 1 year ago ·

Thanks, worked here :)

over 1 year ago ·

Im glad it is working for everyone! :D

over 1 year ago ·

Same here, thank you

over 1 year ago ·

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?

over 1 year ago ·

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.

over 1 year ago ·

This happens when postgres server is not running.
Steps to properly install Postgres via Homebrew on MAC :

  1. brew install postgres

  2. 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]

  3. 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.]

over 1 year ago ·