# 429 Too Many Requests

A throttle middleware counted too many requests for one key. Key the limiter on the user or the real IP, trust your proxy, and honour Retry-After.

Message:

```text
Too Many Attempts.
```

Exception:

```text
Illuminate\Http\Exceptions\ThrottleRequestsException
```

## What it means

A `throttle` middleware counted more requests for one key than its limit allows in the time window, and answered 429 without running the route. It throws `Illuminate\Http\Exceptions\ThrottleRequestsException` with the message `Too Many Attempts.` The 429 response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining: 0`, `Retry-After` with the seconds to wait, and `X-RateLimit-Reset` with the Unix time the count resets. A request the limiter lets through carries only `X-RateLimit-Limit` and `X-RateLimit-Remaining`.

A fresh Laravel 13 app throttles nothing. The `web` group has no throttle, and the `api` group gets `throttle:api` only after you call `$middleware->throttleApi()` in `bootstrap/app.php`. That call also needs an `api` limiter: without one, API requests fail with a 500 and `Rate limiter [api] is not defined.`, or `Rate limiter [App\Models\User::api] is not defined.` for a logged-in user. So a 429 comes from a `throttle` that your code, a package or a starter kit added.

## Why it happens

- A limit too tight for real use, such as a few requests a minute on a page people reload or an endpoint a dashboard calls several times per view.
- One key for every visitor. A named limiter without `by()` keeps one count for everybody: with `Limit::perMinute(3)`, the fourth request got a 429 even from a new address.
- A proxy Laravel does not trust. Behind a load balancer, `$request->ip()` is the balancer's address unless it is trusted, so `throttle:60,1` counts all guests together, and a limiter keyed with `by($request->ip())` counts everybody together. Laravel trusts proxies by itself only on Laravel Cloud and on Forge and Vapor's own `on-forge.com` and `on-vapor.com` domains.
- A frontend that polls. A page that polls every few seconds spends its allowance, and each open tab adds to the same count.
- A login throttle. The Livewire starter kit allows five login attempts a minute per email address and IP address, then answers 429.

## How to fix it

Key the limiter on the user, with the IP address for guests. Define it in the `boot` method of `AppServiceProvider`:

```php
<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
        });
    }
}
```

Then attach it with `->middleware('throttle:api')`, or with `throttleApi()` for the whole `api` group.

Behind a load balancer, trust its addresses inside the `withMiddleware` closure in `bootstrap/app.php`, so `$request->ip()` reads the client's address from `X-Forwarded-For`:

```php
<?php

$middleware->trustProxies(at: ['10.0.0.0/8']);
```

With the proxy trusted, five addresses each got their own count. The docs also allow `at: '*'` for cloud balancers with unknown addresses. Use that only when clients cannot reach the app directly, because a trusted caller can set `X-Forwarded-For` to any address it likes.

For a limit that is too tight, raise it to what real use needs. For polling, poll less often, or push updates instead.

On the client, read `Retry-After` on a 429 and wait that many seconds before the next try. Watch `X-RateLimit-Remaining` on successful responses to slow down before you reach zero.

## Find it in production

With `APP_DEBUG=false`, a visitor gets a 429 page titled "Too Many Requests", and a JSON request gets `{"message": "Too Many Attempts."}`. Laravel does not report it: `ThrottleRequestsException` extends Symfony's `TooManyRequestsHttpException`, an `HttpException`, which is on the `$internalDontReport` list in `Illuminate\Foundation\Exceptions\Handler`. After a run of 429s, `storage/logs/laravel.log` stayed empty, and nothing reaches an error tracker. Count the 429s in your web server's access log instead, for example with nginx's default log format:

```bash
grep '" 429 ' /var/log/nginx/access.log
```

Reproduced on Laravel 13.45, PHP 8.5, 5 December 2026.

Read more: https://laravel.com/docs/routing

## Related

### Terms

- [Rate limiting in Laravel](https://ranetrace.com/glossary/rate-limiting-in-laravel.md)
- [Middleware groups in Laravel](https://ranetrace.com/glossary/middleware-groups-in-laravel.md)
- [HTTP status code](https://ranetrace.com/glossary/http-status-code.md)

### Other errors

- [419 Page Expired](https://ranetrace.com/error-guides/laravel-419-page-expired.md)

Read this guide in a browser: https://ranetrace.com/error-guides/laravel-429-too-many-requests
