Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddRateLimiter' in the application startup code. is thrown by app.UseRateLimiter() when the services were never registered. Add builder.Services.AddRateLimiter(...) before builder.Build(), with the policies your endpoints name, and the app starts.

In this test the endpoint asked for a policy called fixed, so the fix was AddRateLimiter with a fixed window limiter of that name. The first request after the fix returned 200.

The error

The app stopped at startup. The exception went to the server console's standard error stream, nothing was written to standard output, and the curl.exe request that followed got no answer:

Unhandled exception. System.InvalidOperationException: Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddRateLimiter' in the application startup code.
   at Microsoft.AspNetCore.Builder.RateLimiterApplicationBuilderExtensions.VerifyServicesAreRegistered(IApplicationBuilder app)
   at Microsoft.AspNetCore.Builder.RateLimiterApplicationBuilderExtensions.UseRateLimiter(IApplicationBuilder app)
   at Program.<Main>$(String[] args) in ...\lab\Program.cs:line 5

The long scratch path before \lab\Program.cs is shortened; nothing else is changed.

Why it happens

The code that produced it:

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

app.UseRateLimiter();

app.MapGet("/quote", () => "Quote for Maria Garcia").RequireRateLimiting("fixed");

app.Run();

UseRateLimiter checks for its services the moment it is called, and the stack trace shows that check (VerifyServicesAreRegistered) failing on line 5, the UseRateLimiter line. That is why the app never reached app.Run(): no "Now listening" line was printed. The rate limiter's types ship with ASP.NET Core, so the project compiled without any extra package, which makes the missing registration easy to miss.

The fix

using Microsoft.AspNetCore.RateLimiting;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRateLimiter(options =>
{
    options.AddFixedWindowLimiter("fixed", limiter =>
    {
        limiter.PermitLimit = 2;
        limiter.Window = TimeSpan.FromSeconds(30);
        limiter.QueueLimit = 0;
    });
});

var app = builder.Build();

app.UseRateLimiter();

app.MapGet("/quote", () => "Quote for Maria Garcia").RequireRateLimiting("fixed");

app.Run();
PS> curl.exe -s -i http://127.0.0.1:15630/quote
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Sat, 14 Nov 2026 01:16:18 GMT
Server: Kestrel
Transfer-Encoding: chunked

Quote for Maria Garcia

Two changes went in: the using Microsoft.AspNetCore.RateLimiting; line, which brings in AddFixedWindowLimiter, and the AddRateLimiter block before builder.Build(). Everything after Build() stayed exactly as it was in the broken version. Keep the name in AddFixedWindowLimiter("fixed", ...) the same as the name in RequireRateLimiting("fixed"). One thing to know before you ship this configuration: a request over the limit is answered with 503, not 429, unless you set RejectionStatusCode. That is measured in the rate limiter 503 post.

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 package was added for the rate limiter. The broken version exited during startup before it printed a single log line; the fixed one answered a curl.exe request on port 15630 with 200.

Frequently asked

How do I fix 'Please add all the required services by calling IServiceCollection.AddRateLimiter'?
Call builder.Services.AddRateLimiter(...) before builder.Build(), and add the policies your endpoints name, for example AddFixedWindowLimiter("fixed", ...). Then app.UseRateLimiter() finds its services.
When does the AddRateLimiter error appear?
At startup, on the app.UseRateLimiter() line. In the test the app printed the unhandled exception and exited before it listened on its port.
Do I need a NuGet package for the ASP.NET Core rate limiter?
Not in the test on net10.0. The project had no rate limiting package; AddRateLimiter, UseRateLimiter and RequireRateLimiting compiled from the shared framework.

More decoded errors in the Fixes category.