A Practical Guide to Rate Limiting and Brute Force Protection
Limiting how many requests a client can make in a given time, especially to login, password reset and API endpoints, to slow down automated attacks.
On this page
The key figures
- Targets
- login, registration, password reset, search and API endpoints
- Status code
- 429 Too Many Requests
- Retry-After header
- tells clients when they may try again
- Credential stuffing
- attacks using leaked passwords from other sites
Why this is worth getting right
Without limits, attackers can try thousands of passwords or overwhelm expensive endpoints, and rate limiting is a cheap, effective defense.
Do this, not that
Do
- Rate-limit authentication endpoints by account and IP
- Return 429 with Retry-After
- Add multi-factor authentication for sensitive accounts
- Monitor failed login patterns
- Use CAPTCHA or challenges only as a last step
Don’t
- Unlimited login attempts
- Locking accounts permanently after a few failures
- Limits that block legitimate shared networks
- Error messages that reveal whether an account exists
When to bring in help
Our advice Bring in help when facing credential stuffing attacks, or when API costs spike from abusive traffic.
Where this comes from
- OWASP — Authentication Cheat Sheet
- MDN Web Docs — 429 Too Many Requests
The figures and practices above come from the sources listed.
Working on something like this?
We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.