{
  "id": "python/django-database-connection-error",
  "signature": "django.db.utils.OperationalError: could not connect to server: Connection refused Is the server running on host \"localhost\" (127.0.0.1) and accepting TCP/IP connections on port 5432?",
  "signature_zh": "数据库操作错误：无法连接到服务器：连接被拒绝，服务器是否在主机\"localhost\"（127.0.0.1）上运行并接受5432端口的TCP/IP连接？",
  "regex": "django\\.db\\.utils\\.OperationalError:\\ could\\ not\\ connect\\ to\\ server:\\ Connection\\ refused\\ Is\\ the\\ server\\ running\\ on\\ host\\ \"localhost\"\\ \\(127\\.0\\.0\\.1\\)\\ and\\ accepting\\ TCP/IP\\ connections\\ on\\ port\\ 5432\\?",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "PostgreSQL数据库未启动或连接配置错误",
  "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": "",
      "why_fails": "如果数据库未启动，更改主机地址无效",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "可能影响生产环境兼容性",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "sudo service postgresql start 或 systemctl start postgresql",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "确保DATABASES设置中的NAME、USER、PASSWORD正确",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}