By default, my PostgreSQL installation was creating a socket in /tmp but my psql command-line client was looking in /var/run/postgresql/.s.PGSQL.5432.
To remedy this, I edited postgresql.conf and changed the directory to
unix_socket_directories = '/var/run/postgresql/'
Unfortunately, there is by default, no postgresql directory in the var/run directory. So, I created it and started the server, and it all worked well. As soon as I shutdown and restart the server, for some reason the /var/run/postgresql directory disappears. This causes the startup of postgres to crash with an error:
FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
Help appreciated!
/var/runis a symlink to/run, where files (mainly PID files and lock files) are created on the fly. If you want a permanent location for the PID file, put it somewhere else, like/var/postgres-socket/or something. – Jos Jul 08 '16 at 11:43psqlclient to look there? – sparkyspider Jul 08 '16 at 13:37psql -h /var/postgres-socket/should work. See https://www.postgresql.org/docs/9.3/static/libpq-connect.html. – Jos Jul 08 '16 at 13:48