QuestionOur load test logs in hundreds of different users from a single machine, and after a while
MetaService.login starts answering HTTP 429
errors.auth.login_rate_limited. How do we get past it without weakening the protection for real users?
AnswerAdd the test machine's IP to
loginRateLimitExemptIps in
AppSettings. An exempt IP is treated like loopback: its attempts are never limited and never counted.
Why it happensMetaService.login checks the limits before it verifies credentials or captcha. There are two:
- Per user: always on, not configurable. 5 wrong passwords in 5 minutes on the same username lock that user for 1 minute; a successful login resets the counter.
- Per IP:
loginRateLimitPerIpPerMinute (since 1.7.16). It counts every attempt, successful or not, and once exceeded the IP is locked for 1 minute. The default is 0, which means off; a non-numeric or negative value also means off.
The 429 response carries
retryAfterSeconds but deliberately does not say which limit was hit, so it does not reveal whether a username exists. If you never set the per-IP key, the per-user limit is the one you are hitting (for example a test that reuses one account with a wrong password). If you did set it, hundreds of logins from one IP will trip it.
The fix
{
"AppSettings": {
"loginRateLimitPerIpPerMinute": "30",
"loginRateLimitExemptIps": "10.0.2.2, 192.168.1.50"
}
}
- Entries are comma-separated and matched exactly, no ranges. The IPv4-mapped form
::ffff:10.0.2.2 is equivalent to 10.0.2.2. - A VirtualBox guest in NAT sees the host as
10.0.2.2. - Both keys are read at every login, so no restart is needed if your configuration reloads by itself; otherwise recycle the application pool.
- Keep the per-IP limit on for installations exposed to the internet: it is the only defense against credential stuffing (many usernames from one IP). Exempt only the machines you control.
Documentation: Authentication & Authorizations