Databaseexit code > 0

psql: could not connect to server: No such file

$psql: error: 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"?

Analysis

The PostgreSQL client cannot find the Unix domain socket file, usually because the server is not running or is configured to use a different socket directory.

Common Triggers

  • Postgres service is down.
  • Version mismatch (client looking in /tmp, server in /var/run/postgresql).

Debug Checks

  • $Check status: systemctl status postgresql.

Resolution

1
Start the service.
2
Specify host as localhost to force TCP: psql -h localhost ....

Metadata

Tool
Database
Severity
High
Tags
#database#postgres#socket