I am running a custom postgres 14.2 installation (via Ansible, but I do not think that matters here) which has a problem with running the client
postgres@server:> psql
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
systemctl status postgresql
as well as pg_ctl status
show the server is running, so it seems it may be a problem with where the psql client is lookin for the socket.
the configuration should point to /tmp
> grep 'unix_socket_directories' $PGDATA/postgresql.conf
#unix_socket_directories = '/tmp'
psql -h /tmp
works. Also I can work around this by export PGHOST=/tmp
and then running plain psql
.
EDIT: owerwriting the default with an explicit unix_socket_directories = '/tmp'
did not do any good.
Can anybody advise what may be the root cause here and how to get around psql searching the wrong path for the socket?