{
  "id": "python/sqlalchemy-connection-refused",
  "signature": "sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused\n\tIs the server running on host \"localhost\" (::1) and accepting TCP/IP connections on port 5432?",
  "signature_zh": "sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) 无法连接到服务器：连接被拒绝\n\t服务器是否在主机 \"localhost\" (::1) 上运行并接受端口 5432 的 TCP/IP 连接？",
  "regex": "sqlalchemy\\.exc\\.OperationalError:\\ \\(psycopg2\\.OperationalError\\)\\ could\\ not\\ connect\\ to\\ server:\\ Connection\\ refused\\\n\\\tIs\\ the\\ server\\ running\\ on\\ host\\ \"localhost\"\\ \\(::1\\)\\ and\\ accepting\\ TCP/IP\\ connections\\ on\\ port\\ 5432\\?",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The database server is not running or not accepting connections on the specified host and port.",
  "root_cause_type": "generic",
  "root_cause_zh": "数据库服务器未运行或未在指定的主机和端口上接受连接。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Changing the port number arbitrarily",
      "why_fails": "The database is not listening on that port either.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Disabling firewall completely",
      "why_fails": "This is a security risk and may not solve the issue if the server is not running.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Start the database server",
      "success_rate": 0.95,
      "how": "# For PostgreSQL:\nsudo systemctl start postgresql\n# Or:\npg_ctl start",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check if the server is listening on the correct interface",
      "success_rate": 0.9,
      "how": "sudo netstat -tulpn | grep 5432\n# If not, edit postgresql.conf to listen on '*' or '0.0.0.0'",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-06-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}