Diagnostic Queries
Symptoms
A client tried to connect over a Unix-domain socket that does not exist. The driver reports SQLSTATE 08001 (sqlclient_unable_to_establish_sqlconnection).
- No socket file at the expected path.
- Common when the server is down or uses a different socket directory.
- A hint asks whether the server is running locally and accepting socket connections.
What the server log shows
could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/tmp/.s.PGSQL.5432"?
Why PostgreSQL raises this — what the manual says
Section 32.1.2 Parameter Key Words (host):
“The default behavior when host is not specified, or is empty, is to connect to a Unix-domain socket in /tmp (or whatever socket directory was specified when PostgreSQL was built).”
For local connections, libpq looks for a Unix-domain socket file in a specific directory. If that file is absent (server down, or a different unix_socket_directories), there is nothing to connect to and the client reports 08001.
Common causes
- The PostgreSQL server is not running.
- The server uses a different socket directory than the client expects.
- A mismatched port in the socket file name.
How to fix it
- Start the server, and confirm it creates the socket.
- Match the client’s socket directory to the server’s
unix_socket_directories(usehost=). - Connect via TCP (
host=localhost) if sockets aren’t available.
Related & next steps
Reference: PostgreSQL 18 Section 34.1 “Connection Control”.
Thanks — noted. This helps keep the database accurate.