HTTP/1.1 503 Service Unavailable with an empty body from an endpoint behind
RequireRateLimiting is the ASP.NET Core rate limiter turning a request away,
not a server that is down. In this test the limiter answered 503 because
RejectionStatusCode was not set. Set
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests in
AddRateLimiter and the same rejected request gets
429 Too Many Requests.
The difference matters to callers: the status line says "Service Unavailable" for 503 and "Too Many Requests" for 429, and a client that reads only the status gets the wrong story from the first one.
The error
The policy allowed two requests per 30-second window with no queue. Three requests in a row; the first two were answered normally, the third got this (nothing was logged in the server console at the template's default log levels):
PS> curl.exe -s -i http://127.0.0.1:15630/quote
HTTP/1.1 503 Service Unavailable
Content-Length: 0
Date: Sat, 14 Nov 2026 01:16:20 GMT
Server: Kestrel
Why it happens
The configuration that produced it:
...
builder.Services.AddRateLimiter(options =>
{
options.AddFixedWindowLimiter("fixed", limiter =>
{
limiter.PermitLimit = 2;
limiter.Window = TimeSpan.FromSeconds(30);
limiter.QueueLimit = 0;
});
});
...
app.UseRateLimiter();
app.MapGet("/quote", () => "Quote for Maria Garcia").RequireRateLimiting("fixed");
...
Nothing in it mentions a status code, so the third request got the limiter's default, which on this machine was 503. There was no body and no header that named the rate limiter. What told the two apart in this run was the pattern: the first two requests in the window answered 200 and the third, sent in the same second, answered 503.
The fix
...
builder.Services.AddRateLimiter(options =>
{
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
options.AddFixedWindowLimiter("fixed", limiter =>
{
limiter.PermitLimit = 2;
limiter.Window = TimeSpan.FromSeconds(30);
limiter.QueueLimit = 0;
});
});
...
With that one line added, the same three requests gave 200, 200 and then:
PS> curl.exe -s -i http://127.0.0.1:15630/quote
HTTP/1.1 429 Too Many Requests
Content-Length: 0
Date: Sat, 14 Nov 2026 01:16:23 GMT
Server: Kestrel
Only the status changed: the response still had Content-Length: 0 and no
Retry-After header, and the first two requests in the window still returned
200 with the quote.
How it was reproduced
A minimal API made with dotnet new web -f net10.0 on SDK 11.0.100, running on
Microsoft.AspNetCore.App 10.0.15 in the Development environment, built and started by a small script, start.ps1, which runs dotnet build -nologo -v q in the project folder and then bin\Debug\net10.0\FixLab.exe --urls http://127.0.0.1:15630, no extra package for the rate
limiter. Three curl.exe -s -i requests within the same second against a fixed
window of two permits, before and after setting RejectionStatusCode.
Frequently asked
- Why does the ASP.NET Core rate limiter return 503 instead of 429?
- RejectionStatusCode was not set in AddRateLimiter. In the test the rejected request got 503 Service Unavailable with an empty body until RejectionStatusCode was set to 429.
- How do I make the ASP.NET Core rate limiter return 429 Too Many Requests?
- Inside builder.Services.AddRateLimiter, set options.RejectionStatusCode = StatusCodes.Status429TooManyRequests. The same over-limit request then returned 429 in the test.
- What does a rate limiter 503 look like in ASP.NET Core?
- In the test the first two requests in the 30-second window returned 200 and the third, sent in the same second, returned 503 with Content-Length: 0 and no other header naming the limiter.
More decoded errors in the Fixes category. If the app
does not start at all after you add UseRateLimiter, see
'Unable
to find the required services ... AddRateLimiter'.