# Rate Limits

> The per-IP limits on authentication endpoints, how to change one, and how they behave locally and in e2e.

*Canonical: https://makerkit.dev/docs/void-cloudflare/authentication/rate-limits*

---

Better Auth limits auth requests per client IP. Counters live in the database (the `rate_limit` table), so every Worker isolate shares them.

This page is part of the [Authentication documentation](./overview). Limits for routes that are not sign-in (an upload, a contact form) are in [Operations: Rate Limits](../operations/rate-limits).

## The Limits

| Endpoint | Limit per IP |
|---|---|
| `/api/auth/sign-in/email` | 5 a minute |
| `/api/auth/sign-up/email` | 3 a minute |
| `/api/auth/change-password` | 5 every 10 minutes (the current password is guessed here too) |
| `/api/auth/link-social` | 10 every hour (each one starts a provider redirect) |
| `/api/auth/request-password-reset` | 3 every 5 minutes |
| `/api/auth/send-verification-email` | 3 every 5 minutes |
| `/api/auth/sign-in/magic-link` | 3 every 5 minutes |
| `/api/auth/magic-link/verify` | 5 a minute (the plugin's own) |
| `/api/auth/email-otp/send-verification-otp` | 3 every 5 minutes |
| `/api/auth/sign-in/email-otp` | 5 a minute, and 3 wrong tries per code |
| `/api/auth/sign-in/social` | 10 a minute (each starts an OAuth redirect) |
| each `/api/auth/two-factor/*` endpoint | 3 every 10 seconds (Better Auth's own), 5 wrong codes per sign-in, and a 15-minute lock after 10 in a row ([Two-Factor](./two-factor)) |
| `/api/auth/passkey/generate-authenticate-options`, `/api/auth/passkey/verify-authentication` | 10 a minute each ([Passkeys](./passkeys)) |
| `/api/auth/organization/create` | 5 a minute |
| `/api/auth/stripe/webhook` | 10,000 a minute (Stripe's signed webhooks come from a few addresses, and a burst of billing events must not be refused) |
| anything else under `/api/auth` | 100 a minute |

**Per address**, whatever the IP: one email address gets at most 10 sign-in codes in 24 hours, counted from its first code (`EMAIL_OTP_CODES_PER_ADDRESS`, `EMAIL_OTP_CODES_WINDOW_HOURS`). Each code allows 3 wrong tries, so guesses against one account stay at 30 per window however many IPs an attacker has. It stays on with `AUTH_RATE_LIMIT=false`, and addresses that aren't valid emails are refused before anything is counted.

**Per user**, whatever the IP: one user changes their display name at most 20 times an hour (`NAME_CHANGES_PER_WINDOW`, `NAME_CHANGES_WINDOW_HOURS` in `packages/better-auth/src/constants.ts`), over HTTP and from server code (`auth.api.updateUser`) alike. Email change requests: 3 an hour (`EMAIL_CHANGES_PER_WINDOW`), an address another account owns included. Saving the same name isn't counted. The Profile page answers the 21st with "You've changed your name too many times. Try again later."

The cost: anyone can use up an address's codes, and its owner then can't get a code until the window ends. With other methods on (password, magic link) they sign in another way; if codes are the only method, that address can't sign in until then. Keep a second method on if that matters to you.

A blocked request gets `429`; the forms show "Too many attempts. Wait a minute and try again."

The defaults are `AUTH_RATE_LIMIT_RULES` in `packages/better-auth/src/rate-limit.ts`. Plugins added later keep their own limits.

## Changing a Limit

Override single rules in your config, inside the object `createAuthConfig()` returns (replace `rateLimitRules: {}`); the rest keep their defaults:

```ts {% title="apps/web/config/auth.config.server.ts" %}
rateLimitRules: {
  // many users behind one office IP
  '/sign-in/email': { window: 60, max: 20 },
},
```

`window` is in seconds. Paths are Better Auth's, without `/api/auth`, matched exactly.

## The Client IP

The IP comes from Cloudflare's `cf-connecting-ip` header, which Cloudflare sets on every request. `x-forwarded-for` is ignored: clients can set it.

Per-IP limits slow guessing from one address. An attacker spread over many addresses needs captcha on top: [Turnstile](./captcha) on the forms bots abuse.

## Turning Them Off

`AUTH_RATE_LIMIT=false` turns them off. Keep them on when deployed.

Locally every request comes from `127.0.0.1`, so a few quick sign-in retries can hit a limit; set `AUTH_RATE_LIMIT=false` in `apps/web/.env` if that gets in your way. E2E needs them on: each test sends its own made-up IP (see [Testing](./testing)).
