rwgkzw
Last Updated: January 04, 2018
·
32.36K
· 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

11841

Removing that file worked for me. Thank you!

over 1 year ago ·
13451

Thank you, that worked

over 1 year ago ·
14206

Thanks, worked here :)

over 1 year ago ·
14722

Im glad it is working for everyone! :D

over 1 year ago ·
20796

Same here, thank you

over 1 year ago ·
28607

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

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

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

9 months ago ·