{
  "id": "kubernetes/ingress-nginx-502-bad-gateway-upstream",
  "signature": "502 Bad Gateway (Ingress/Nginx) — upstream prematurely closed connection",
  "signature_zh": "502 网关错误（Ingress/Nginx）— 上游连接过早关闭",
  "regex": "502 Bad Gateway.*upstream prematurely closed connection",
  "domain": "kubernetes",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The backend service (upstream) is not responding or closes connections prematurely, often due to high load or misconfigured timeouts.",
  "root_cause_type": "generic",
  "root_cause_zh": "后端服务（上游）无响应或过早关闭连接，通常由于负载过高或超时配置错误。",
  "versions": [
    {
      "version": "ingress-nginx 1.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kubernetes 1.27",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Only temporarily clears the issue; the upstream problem remains.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not address the upstream service's inability to handle connections.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May mask the issue but can cause resource exhaustion if upstream is truly broken.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check upstream service health: `kubectl get pods -l app=<service>` and `kubectl logs <pod>`. Increase resources or add horizontal pod autoscaling if under load.",
      "success_rate": 0.85,
      "how": "Check upstream service health: `kubectl get pods -l app=<service>` and `kubectl logs <pod>`. Increase resources or add horizontal pod autoscaling if under load.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add ingress annotation to adjust timeouts: `nginx.ingress.kubernetes.io/proxy-read-timeout: '600'` and `nginx.ingress.kubernetes.io/proxy-send-timeout: '600'`.",
      "success_rate": 0.8,
      "how": "Add ingress annotation to adjust timeouts: `nginx.ingress.kubernetes.io/proxy-read-timeout: '600'` and `nginx.ingress.kubernetes.io/proxy-send-timeout: '600'`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "检查上游服务健康状态：`kubectl get pods -l app=<service>` 和 `kubectl logs <pod>`。如果负载过高，增加资源或启用水平 Pod 自动伸缩。",
    "添加 Ingress 注释以调整超时：`nginx.ingress.kubernetes.io/proxy-read-timeout: '600'` 和 `nginx.ingress.kubernetes.io/proxy-send-timeout: '600'`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-timeouts",
  "official_doc_section": null,
  "error_code": "502",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}