{
  "id": "api/http-502-bad-gateway-upstream-unreachable",
  "signature": "502 Bad Gateway: upstream server unreachable",
  "signature_zh": "502 错误网关：上游服务器不可达",
  "regex": "502\\s*(?:Bad Gateway)?[\\s\\S]*upstream\\s*(?:server\\s*)?(?:unreachable|timed?\\s*out|refused\\s*connection)",
  "domain": "api",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The API gateway or reverse proxy received an invalid response from the upstream server, often due to the upstream being down, overloaded, or misconfigured in the load balancer.",
  "root_cause_type": "generic",
  "root_cause_zh": "API 网关或反向代理从上游服务器收到无效响应，通常是由于上游服务器宕机、过载或负载均衡器配置错误。",
  "versions": [
    {
      "version": "Nginx 1.24+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "HAProxy 2.8+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "AWS ALB (2024)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The upstream server itself is unhealthy; restarting the gateway does not fix the upstream issue.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If the upstream is down, timeouts only delay failure detection; the root cause (e.g., crashed service) remains.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "While DNS can cause this, the error often stems from upstream service failure (e.g., port 8080 not listening), not DNS resolution.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check upstream server health via a health check endpoint (e.g., `/health`). Example: `curl -I http://upstream-service:8080/health`. If it fails, restart the upstream service or check its logs.",
      "success_rate": 0.9,
      "how": "Check upstream server health via a health check endpoint (e.g., `/health`). Example: `curl -I http://upstream-service:8080/health`. If it fails, restart the upstream service or check its logs.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify load balancer configuration, ensuring the upstream server is correctly listed and the port matches. Example: `nginx -t` to test Nginx config, then `systemctl reload nginx`.",
      "success_rate": 0.85,
      "how": "Verify load balancer configuration, ensuring the upstream server is correctly listed and the port matches. Example: `nginx -t` to test Nginx config, then `systemctl reload nginx`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Temporarily bypass the gateway by hitting the upstream directly (if network permits) to isolate the issue. Example: `curl http://10.0.1.5:8080/api/v1/resource`.",
      "success_rate": 0.8,
      "how": "Temporarily bypass the gateway by hitting the upstream directly (if network permits) to isolate the issue. Example: `curl http://10.0.1.5:8080/api/v1/resource`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过健康检查端点（例如 `/health`）检查上游服务器健康状态。示例：`curl -I http://upstream-service:8080/health`。如果失败，重启上游服务或检查其日志。",
    "验证负载均衡器配置，确保上游服务器正确列出且端口匹配。示例：`nginx -t` 测试 Nginx 配置，然后 `systemctl reload nginx`。",
    "临时绕过网关直接访问上游（如果网络允许）以隔离问题。示例：`curl http://10.0.1.5:8080/api/v1/resource`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-06-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}