{
  "id": "cloud/azure-app-service-http-502-bad-gateway",
  "signature": "HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure",
  "signature_zh": "HTTP 错误 502.5 - ANCM 进程外启动失败",
  "regex": "502\\.5 - ANCM Out-Of-Process Startup Failure",
  "domain": "cloud",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "ASP.NET Core application hosted on Azure App Service fails to start due to missing runtime dependencies, incorrect startup command, or port mismatch between the application and the IIS ANCM module.",
  "root_cause_type": "generic",
  "root_cause_zh": "托管在 Azure 应用服务上的 ASP.NET Core 应用程序因缺少运行时依赖项、启动命令不正确或应用程序与 IIS ANCM 模块之间的端口不匹配而无法启动。",
  "versions": [
    {
      "version": "Azure App Service Windows",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET 6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET 8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ASP.NET Core Module 18.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The application binary or its dependencies are still broken; restarting only re-executes the same failing startup sequence.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The stdout log may show generic messages; the actual error (e.g., 'Could not load file or assembly') is often written to stderr or the Windows Event Log.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Enable detailed error logging via `appsettings.json`: set `\"ASPNETCORE_DETAILEDERRORS\": \"true\"` and `\"ASPNETCORE_ENVIRONMENT\": \"Development\"` in the App Settings blade; then redeploy and check the stdout log at `D:\\home\\LogFiles\\stdout\\`. Fix any missing NuGet packages or framework versions.",
      "success_rate": 0.85,
      "how": "Enable detailed error logging via `appsettings.json`: set `\"ASPNETCORE_DETAILEDERRORS\": \"true\"` and `\"ASPNETCORE_ENVIRONMENT\": \"Development\"` in the App Settings blade; then redeploy and check the stdout log at `D:\\home\\LogFiles\\stdout\\`. Fix any missing NuGet packages or framework versions.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the application listens on the correct port by adding `UseUrls` in `Program.cs` or setting the `PORT` environment variable to `8080` (the default port ANCM expects). Example: `webBuilder.UseUrls(\"http://*:8080\");` in `CreateHostBuilder`.",
      "success_rate": 0.8,
      "how": "Ensure the application listens on the correct port by adding `UseUrls` in `Program.cs` or setting the `PORT` environment variable to `8080` (the default port ANCM expects). Example: `webBuilder.UseUrls(\"http://*:8080\");` in `CreateHostBuilder`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Enable detailed error logging via `appsettings.json`: set `\"ASPNETCORE_DETAILEDERRORS\": \"true\"` and `\"ASPNETCORE_ENVIRONMENT\": \"Development\"` in the App Settings blade; then redeploy and check the stdout log at `D:\\home\\LogFiles\\stdout\\`. Fix any missing NuGet packages or framework versions.",
    "Ensure the application listens on the correct port by adding `UseUrls` in `Program.cs` or setting the `PORT` environment variable to `8080` (the default port ANCM expects). Example: `webBuilder.UseUrls(\"http://*:8080\");` in `CreateHostBuilder`."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/web-apps-open-source-technologies-faqs#http-error-5025---ancm-out-of-process-startup-failure",
  "official_doc_section": null,
  "error_code": "502.5",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "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": []
}