SQLSTATE 08001 FATAL Class 08: Connection Exception

sqlclient_unable_to_establish_sqlconnection could not connect to server: No such file or directory — 08001

PostgreSQL error “could not connect to server: No such file or directory — 08001” (SQLSTATE 08001): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

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

  1. Start the server, and confirm it creates the socket.
  2. Match the client’s socket directory to the server’s unix_socket_directories (use host=).
  3. Connect via TCP (host=localhost) if sockets aren’t available.

Related & next steps

Reference: PostgreSQL 18 Section 34.1 “Connection Control”.

Was this helpful?