Other 5xx codes
All HTTP status codes in ASP.NET Core
5xx Server error
A gateway or proxy got an invalid response from the server behind it.
In ASP.NET Core: Usually comes from a reverse proxy (nginx, YARP, Azure Front Door) when your app crashed or refused the connection.
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 502.
| Constant | StatusCodes.Status502BadGateway |
|---|---|
| HttpStatusCode | HttpStatusCode.BadGateway |
| Reason phrase | Kestrel sends Bad Gateway |
| Class | 5xx, server error |
| IsSuccessStatusCode | false |
| EnsureSuccessStatusCode() | throws HttpRequestException: Response status code does not indicate success: 502 (Bad Gateway). |
| Standard resilience handler | retries it (treated as transient) |
Results.StatusCode(StatusCodes.Status502BadGateway)
Results.Problem(statusCode: StatusCodes.Status502BadGateway, detail: "...")StatusCode(StatusCodes.Status502BadGateway)
Problem(statusCode: StatusCodes.Status502BadGateway, detail: "...")What Results.Problem(statusCode: 502) sends (with AddProblemDetails()), as application/problem+json:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.6.3",
"title": "Bad Gateway",
"status": 502,
"traceId": "0HNA1B2C3D4E5:00000001"
}A controller's Problem(statusCode: 502) sends the same body.
A bare StatusCode(502) in an [ApiController] also gets a ProblemDetails body automatically; Results.StatusCode(502) in a minimal API sends an empty body unless you add UseStatusCodePages().
Every response on this page was recorded from ASP.NET Core 10.0.12 on Kestrel in the Production environment; the HttpClient rows come from .NET 10.0.12 and Microsoft.Extensions.Http.Resilience 10.10.0.
All HTTP status codes in ASP.NET Core