{
  "id": "database/postgresql-cannot-connect-to-server-no-such-file-or-directory",
  "signature": "psycopg2.OperationalError: could not connect to server: No such file or directory\n\tIs the server running locally and accepting connections on Unix domain socket \"/var/run/postgresql/.s.PGSQL.5432\"?",
  "signature_zh": "psycopg2.OperationalError: 无法连接到服务器：没有那个文件或目录\n\t服务器是否在本地运行并通过 Unix 域套接字 \"/var/run/postgresql/.s.PGSQL.5432\" 接受连接？",
  "regex": "could not connect to server: No such file or directory\\n\\tIs the server running locally and accepting connections on Unix domain socket",
  "domain": "database",
  "category": "connection_error",
  "subcategory": null,
  "root_cause": "The PostgreSQL Unix domain socket file does not exist at the expected path, typically because the server is not running, the socket directory is misconfigured, or the client is looking in the wrong location.",
  "root_cause_type": "generic",
  "root_cause_zh": "PostgreSQL Unix 域套接字文件在预期路径上不存在，通常是因为服务器未运行、套接字目录配置错误或客户端在错误的位置查找。",
  "versions": [
    {
      "version": "PostgreSQL 15.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 16.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 14.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the server is not running, TCP/IP connection also fails with 'Connection refused'. This only masks the real issue.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The issue is server-side (socket file missing), not client-side. Reinstalling clients doesn't fix the server.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Start the PostgreSQL server: `sudo systemctl start postgresql` or `pg_ctl start -D /var/lib/postgresql/15/main` (adjust version and data directory).",
      "success_rate": 0.85,
      "how": "Start the PostgreSQL server: `sudo systemctl start postgresql` or `pg_ctl start -D /var/lib/postgresql/15/main` (adjust version and data directory).",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the server is running but socket is in a different directory, set the host parameter to use TCP/IP: `host=localhost port=5432` in the connection string, or set `PGHOST=localhost` environment variable.",
      "success_rate": 0.9,
      "how": "If the server is running but socket is in a different directory, set the host parameter to use TCP/IP: `host=localhost port=5432` in the connection string, or set `PGHOST=localhost` environment variable.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Start the PostgreSQL server: `sudo systemctl start postgresql` or `pg_ctl start -D /var/lib/postgresql/15/main` (adjust version and data directory).",
    "If the server is running but socket is in a different directory, set the host parameter to use TCP/IP: `host=localhost port=5432` in the connection string, or set `PGHOST=localhost` environment variable."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.postgresql.org/docs/current/runtime-connection.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}