Nextcloud "Too Many Requests" With the Right Password? It's Your Reverse Proxy
"Too many requests" with the right password means Nextcloud's brute-force protection has blocked the address you arrive from, and behind a reverse proxy without trusted_proxies that is the proxy's address for everyone. Reset it with occ security:bruteforce:reset to get back in, then set trusted_proxies so only the attacker's own address is blocked. Never allow-list the proxy or switch the protection off.
If Nextcloud answers "Too many requests. There were too many requests
from your network" when you type the right password, your password is
not the problem. Nextcloud's brute-force protection has blocked the
address you are connecting from. Behind a reverse proxy that has not been
declared in trusted_proxies, every visitor arrives with the proxy's
address, so one bot guessing passwords locks out everyone, you included.
We tested every step on a fresh Nextcloud 35.0.1 in Docker
(nextcloud:35.0.1-apache) behind an nginx reverse proxy
(nginx:stable-alpine), with a script on another address making eleven
wrong admin logins through the proxy.
Why does Nextcloud say "Too many requests" when my password is right?
Brute-force protection is built into Nextcloud and on by default. It counts failed logins by the address they come from, not by account. Nextcloud's admin manual says each failure slows the next try, up to 25 seconds, and that once an address has more than 10 failures within the last 30 minutes, it gets "429 Too Many Requests" until that number drops. The check runs before the password is looked at, so the right password is refused too. It lifts by itself about half an hour after the failures stop; a bot that keeps going keeps the block in place.
In our test, before any fix, all eleven failures were logged as
Login failed: admin (Remote IP: 172.31.40.10). That is the proxy's
address, not the script's. The admin logging in with the right password through
the same proxy got the 429 page.
How do I get back into Nextcloud right now?
Find the blocked address in the log, then clear it:
# plain Linux install (adjust the data path)
grep "Login failed" /var/www/nextcloud/data/nextcloud.log | tail -n 3
sudo -u www-data php occ security:bruteforce:attempts 172.31.40.10
sudo -u www-data php occ security:bruteforce:reset 172.31.40.10
# Docker (official image)
docker exec nextcloud grep "Login failed" /var/www/html/data/nextcloud.log | tail -n 3
docker exec -u www-data nextcloud php occ security:bruteforce:reset 172.31.40.10
Replace 172.31.40.10 with the "Remote IP" your log shows and
nextcloud with your container's name. Once you are signed in,
Administration settings → Security shows, under Brute-force
settings, "Your current IP address is detected as …". If that is your proxy's
address, the lockout will come back.
How do I stop it from happening again?
Tell Nextcloud which address is your proxy. It then reads each visitor's real
address from the X-Forwarded-For header the proxy adds, and only the
address that keeps failing gets blocked.
# plain Linux install
sudo -u www-data php occ config:system:set trusted_proxies 0 --value=172.31.40.10
# Docker: an environment variable on the Nextcloud container (space-separated,
# CIDR ranges allowed), then recreate the container
TRUSTED_PROXIES=172.31.40.10
# nginx: pass the visitor's address on (most proxies already do)
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
In our test, after setting trusted_proxies, the Security page
showed the admin at 192.168.20.100, the computer they were signed
in from. The same script's next eleven failures were logged with its own
address (172.31.40.66), the script got the 429, and the admin logged
in normally.
If your proxy is another container, use its address on the Docker network, or
the network's range such as 172.18.0.0/16. With Cloudflare or a chain
of proxies in front, Nextcloud's
reverse
proxy page covers which addresses to trust and forwarded_for_headers.
Should I add my proxy to the brute-force allow list?
No. Addresses on the allow list skip the protection, and every visitor, bots included, arrives as the proxy. Listing it switches brute-force protection off for everybody. The Security page itself says "it is recommended to list as few remote addresses as possible or ideally even none at all", and the manual says false positives "are best handled by fixing the underlying causes (e.g. a misconfigured reverse proxy…)".
Turning the protection off with auth.bruteforce.protection.enabled
in config.php is, in the manual's words, "heavily discouraged for
production servers". Disabling the Brute-force settings app does not turn the
protection off; it only hides the page.
What about fail2ban?
fail2ban can ban an address at the firewall after repeated "Login failed" lines
in nextcloud.log. It is an extra layer on top of the built-in
protection, not a replacement, and it reads the same "Remote IP", so it needs
trusted_proxies set first. Without it, fail2ban would ban your proxy.
Checklist
- "Too many requests" with the right password: a blocked address, not a wrong password.
- Find it ("Login failed … Remote IP" in the log) and run
occ security:bruteforce:reset. - Set
trusted_proxies(Docker:TRUSTED_PROXIES) and make sure the proxy sendsX-Forwarded-For. - Check Administration settings → Security shows your real address.
- Never allow-list the proxy; keep the protection on.
Full video transcript
1
00:00:00,000 --> 00:00:03,806
If Nextcloud says Too many requests
when your password is right,
2
00:00:03,846 --> 00:00:08,013
its brute-force protection has blocked
the address you're coming from.
3
00:00:08,053 --> 00:00:11,558
Behind a reverse proxy, that's
usually the proxy's address.
4
00:00:11,598 --> 00:00:14,202
So one bot locks out
everyone, you included.
5
00:00:14,242 --> 00:00:17,567
I'll get back in with one
command, then fix it for good,
6
00:00:17,607 --> 00:00:19,350
so only the bot gets blocked.
7
00:00:19,750 --> 00:00:22,955
This is Nextcloud thirty
five, freshly installed.
8
00:00:22,995 --> 00:00:26,267
It runs in Docker, on a
Linux server I run myself.
9
00:00:26,307 --> 00:00:29,645
And I'm reaching it through
nginx, a reverse proxy.
10
00:00:29,685 --> 00:00:33,420
That's the usual way to put
Nextcloud on your own domain.
11
00:00:33,460 --> 00:00:35,447
Nothing else has been changed.
12
00:00:36,718 --> 00:00:41,182
Any Nextcloud you can reach from the
internet gets bots guessing passwords.
13
00:00:41,222 --> 00:00:45,506
To play the bot, I've started a script
on another address on my network.
14
00:00:45,546 --> 00:00:49,869
It tries eleven wrong passwords on
the admin account, one after another.
15
00:00:51,133 --> 00:00:53,915
When it's done, I reload the login page.
16
00:00:54,222 --> 00:00:59,559
Too many failed login attempts from your
location. Try again in thirty seconds.
17
00:00:59,599 --> 00:01:02,457
But I haven't typed a single password yet.
18
00:01:03,702 --> 00:01:07,780
So I'll type the admin login,
with the right password.
19
00:01:08,988 --> 00:01:13,414
Too many requests. There were too
many requests from your network.
20
00:01:13,454 --> 00:01:17,203
The password was right.
Nextcloud never even checked it.
21
00:01:17,243 --> 00:01:19,612
It refused the address I came from.
22
00:01:20,865 --> 00:01:25,199
This is Nextcloud's brute-force
protection, and it's on by default.
23
00:01:25,239 --> 00:01:30,030
It counts failed logins by the address
they come from, not by the account.
24
00:01:30,070 --> 00:01:35,449
The manual says each failed try also slows
the next one, up to twenty five seconds.
25
00:01:35,489 --> 00:01:38,909
And after more than ten
failures within half an hour,
26
00:01:38,949 --> 00:01:42,239
that address gets Too many
requests on every login.
27
00:01:42,279 --> 00:01:47,070
Right password or not. The block clears
by itself, once the failures stop.
28
00:01:47,110 --> 00:01:48,612
But a bot doesn't stop.
29
00:01:49,933 --> 00:01:54,136
So why was I blocked? The script
used a different address than mine.
30
00:01:54,176 --> 00:01:57,506
But every visitor reaches
Nextcloud through the proxy.
31
00:01:57,546 --> 00:01:59,940
You, your family's phones, and the bot.
32
00:01:59,980 --> 00:02:04,682
Unless Nextcloud is told otherwise, the
only address it sees is the proxy's.
33
00:02:04,722 --> 00:02:09,901
To Nextcloud, we're all one visitor. And
that one visitor just failed eleven times.
34
00:02:11,193 --> 00:02:14,503
Nextcloud's own manual
warns about exactly this.
35
00:02:14,807 --> 00:02:19,292
Behind a reverse proxy, the trusted
proxies setting needs to be set correctly.
36
00:02:19,332 --> 00:02:19,872
Otherwise,
37
00:02:19,912 --> 00:02:24,687
it can happen that Nextcloud actually starts
throttling all traffic coming from the
38
00:02:24,727 --> 00:02:25,499
reverse proxy.
39
00:02:25,539 --> 00:02:27,396
That's what just happened to me.
40
00:02:28,651 --> 00:02:31,040
First, getting back in, right now.
41
00:02:31,080 --> 00:02:36,471
Every failed login goes into Nextcloud's
log, with the address it came from.
42
00:02:36,511 --> 00:02:38,972
So search the log for Login failed.
43
00:02:39,012 --> 00:02:44,260
Here, every one of those lines has the
proxy's address, ending in dot ten.
44
00:02:44,300 --> 00:02:47,904
Then one command on the
server clears that address.
45
00:02:47,944 --> 00:02:52,231
In Docker, run it through docker
exec, as the www-data user.
46
00:02:54,748 --> 00:02:55,539
I've run it.
47
00:02:55,579 --> 00:03:00,939
The proxy's address now has no failed
logins against it, so the block is gone.
48
00:03:00,979 --> 00:03:04,163
Same login as before,
with the right password.
49
00:03:05,371 --> 00:03:07,922
And I'm in. The reset cleared the block.
50
00:03:07,962 --> 00:03:11,809
But nothing stops the next bot
from doing it again tomorrow.
51
00:03:11,849 --> 00:03:14,506
So let's see what Nextcloud actually saw.
52
00:03:15,764 --> 00:03:18,195
Administration settings, Logging.
53
00:03:20,304 --> 00:03:23,860
Login failed, admin. Remote
IP, ending in dot ten.
54
00:03:23,900 --> 00:03:29,757
Every one of the script's failures says
the same. That isn't the script's address.
55
00:03:29,797 --> 00:03:31,020
It's the proxy's.
56
00:03:32,271 --> 00:03:35,068
Now Administration settings, Security.
57
00:03:36,842 --> 00:03:40,714
Down at Brute-force settings,
Nextcloud shows how it sees me.
58
00:03:40,754 --> 00:03:45,395
Your current IP address is detected
as, again, the one ending in dot ten.
59
00:03:45,435 --> 00:03:48,088
That's me, signed in from my own computer.
60
00:03:48,128 --> 00:03:51,270
Nextcloud sees me at the
same address as the bot.
61
00:03:52,532 --> 00:03:56,906
The lasting fix is to tell Nextcloud
which address is your proxy.
62
00:03:56,946 --> 00:04:00,981
That's the trusted proxies
setting. Set it with one command.
63
00:04:01,021 --> 00:04:06,210
In Docker, you can set the TRUSTED_PROXIES
variable on the container instead,
64
00:04:06,250 --> 00:04:07,297
and recreate it.
65
00:04:07,337 --> 00:04:09,470
Once Nextcloud trusts the proxy,
66
00:04:09,510 --> 00:04:13,952
it reads each visitor's real address
from a header the proxy adds.
67
00:04:13,992 --> 00:04:19,154
In nginx, that's the X forwarded for
line, and most proxies send it already.
68
00:04:21,766 --> 00:04:24,570
I've run the command. Reload the page.
69
00:04:24,964 --> 00:04:29,031
Now my address is detected
as 192.168.20.100.
70
00:04:29,071 --> 00:04:34,051
That's the computer I'm
sitting at, on my home network.
71
00:04:34,091 --> 00:04:38,745
Nextcloud can finally tell
me apart from the proxy.
72
00:04:40,007 --> 00:04:40,933
Let's prove it.
73
00:04:40,973 --> 00:04:45,697
The same script, from its own address,
tries eleven wrong passwords again.
74
00:04:45,737 --> 00:04:50,075
If the fix works, those failures
count against the script's address,
75
00:04:50,115 --> 00:04:51,210
not against mine.
76
00:04:52,463 --> 00:04:54,543
When it's finished, I sign out.
77
00:04:54,848 --> 00:04:57,240
And log in with the right password.
78
00:05:02,107 --> 00:05:06,869
Straight in. The bot made the same
eleven tries, and I wasn't touched.
79
00:05:08,094 --> 00:05:09,375
Back to the log.
80
00:05:12,724 --> 00:05:16,105
The new failures say Remote
IP ending in dot sixty six.
81
00:05:16,145 --> 00:05:21,183
That's the script's own address. So that's
the only address Nextcloud blocks now.
82
00:05:22,423 --> 00:05:24,857
One last stop, back in Security.
83
00:05:27,013 --> 00:05:30,070
Under the status is the
brute-force allow list.
84
00:05:30,110 --> 00:05:32,837
Addresses listed here skip the protection.
85
00:05:32,877 --> 00:05:36,790
It's tempting to add the proxy,
to stop the lockouts. Don't.
86
00:05:36,830 --> 00:05:39,755
Everyone arrives as the
proxy, bots included.
87
00:05:39,795 --> 00:05:43,445
So listing it switches the
protection off for everybody.
88
00:05:43,485 --> 00:05:45,619
Nextcloud's advice is right here.
89
00:05:45,659 --> 00:05:49,481
List as few addresses as
possible, or ideally none at all.
90
00:05:50,781 --> 00:05:55,449
The same goes for switching brute-force
protection off in the config file.
91
00:05:55,489 --> 00:05:58,121
The manual calls that heavily discouraged.
92
00:05:58,161 --> 00:06:02,066
Without it, a bot can guess
passwords for as long as it likes.
93
00:06:02,106 --> 00:06:05,820
A ban tool like fail2ban can
sit on top, as an extra layer.
94
00:06:05,860 --> 00:06:09,383
It reads the same log, so it
needs the real address too.
95
00:06:09,423 --> 00:06:11,205
Trusted proxies comes first.
96
00:06:13,108 --> 00:06:13,277
So.
97
00:06:13,317 --> 00:06:17,886
Too many requests with the right
password means a blocked address,
98
00:06:17,926 --> 00:06:19,352
not a wrong password.
99
00:06:19,392 --> 00:06:21,726
Reset that address to get back in.
100
00:06:21,766 --> 00:06:26,753
Then set trusted proxies, so Nextcloud
sees each visitor's real address,
101
00:06:26,793 --> 00:06:29,057
and blocks only the one guessing.
102
00:06:29,097 --> 00:06:32,897
Never allow-list the proxy,
and keep the protection on.
103
00:06:32,937 --> 00:06:37,156
The exact commands, for Docker
and for a plain Linux install,
104
00:06:37,196 --> 00:06:39,223
are on the page linked below.