Problem:
createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/var/pgsql_socket/.s.PGSQL.5432″?
Solution:
I tried many solutions found across the interwebs to no avail. The problem seems quite common, for me the fix was:
Make sure the daemon is indeed running:
ps aux | grep postgres
Find this .s.PGSQL.5432 file:
sudo find / -name .s.PGSQL.5432
Create a Symbolic Link to the destination it’s “supposed to be located at”:
ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/
Other Possible Solutions
- Try uninstalling postgresql (brew uninstall postgresql), uninstalling the pg gem (gem uninstall pg), move /usr/local/bin to the first line of /etc/path, reboot, install postgresql, install pg gem, more details instructions here: http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
- See Comments here: http://ntcncp.net/2011/09/05/step-by-step-from-setting-up-rails-3-1-development-environment-to-deploying-to-heroku/
- http://www.postgresql.org/docs/8.3/static/server-start.html
- http://stackoverflow.com/questions/6770649/repairing-postgresql-after-upgrading-to-osx-10-7-lion


Hi Iain,
Your post helped me a lot.
Thanks