Other 4xx codes
All HTTP status codes in ASP.NET Core
4xx Client error
The server gave up waiting for the client to finish sending the request.
In ASP.NET Core: Kestrel closes connections whose headers or body arrive too slowly (RequestHeadersTimeout, MinRequestBodyDataRate). HttpClient's resilience handler retries 408.
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 408.
| Constant | StatusCodes.Status408RequestTimeout |
|---|---|
| HttpStatusCode | HttpStatusCode.RequestTimeout |
| Reason phrase | Kestrel sends Request Timeout |
| Class | 4xx, client error |
| IsSuccessStatusCode | false |
| EnsureSuccessStatusCode() | throws HttpRequestException: Response status code does not indicate success: 408 (Request Timeout). |
| Standard resilience handler | retries it (treated as transient) |
Results.StatusCode(StatusCodes.Status408RequestTimeout)
Results.Problem(statusCode: StatusCodes.Status408RequestTimeout, detail: "...")StatusCode(StatusCodes.Status408RequestTimeout)
Problem(statusCode: StatusCodes.Status408RequestTimeout, detail: "...")What Results.Problem(statusCode: 408) sends (with AddProblemDetails()), as application/problem+json:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.9",
"title": "Request Timeout",
"status": 408,
"traceId": "0HNA1B2C3D4E5:00000001"
}A controller's Problem(statusCode: 408) sends the same body.
A bare StatusCode(408) in an [ApiController] also gets a ProblemDetails body automatically; Results.StatusCode(408) in a minimal API sends an empty body unless you add UseStatusCodePages().
Setup
builder.WebHost.ConfigureKestrel(k =>
k.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(2)); // default: 30 secondsRequest
GET / HTTP/1.1
Host: x
(the final empty line never arrives)Response (recorded)
HTTP/1.1 408 Request TimeoutKestrel waits RequestHeadersTimeout (30 seconds by default; 2 in this test) for the complete headers, then answers 408 and closes the connection.
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