ERR_TOO_MANY_REDIRECTS appears when a page keeps sending the browser to another address that eventually sends it back, so the chain never ends and the browser gives up. The usual culprits are two layers both forcing HTTPS or www in opposite directions. Fix it by letting exactly one layer own each redirect.
| Loop | How it happens | Fix |
|---|---|---|
| HTTPS behind a proxy | The proxy talks plain HTTP to the server, which redirects to HTTPS again | Redirect on X-Forwarded-Proto, or redirect at the proxy only |
| www versus bare domain | One layer adds www, another removes it | Choose one host and redirect to it in one place |
| Cookie or login loop | The login page sends you to the account page, which sends you back because the cookie never stuck | Check the cookie's Domain, Path and Secure flags |
| Trailing slash | One rule adds a slash, another strips it | Pick one form for every URL |
Updated
Write each redirect your site performs on its own line as from -> to, enter the address you start at, and the simulator follows the chain the way a browser would. It stops when an address repeats, when no rule matches, or after 20 hops, the limit in the Fetch Standard.
Redirect rules, one per line (from -> to)
http://example.com/ -> https://example.com/
https://example.com/ -> https://www.example.com/
https://www.example.com/ -> https://example.com/Start address
Hops the browser would follow
Loop: the chain returns to https://example.com/, so the browser stops with too many redirects.
One server block catches every HTTP request and sends it straight to the final host.
server {
listen 80;
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
# ssl_certificate lines here
return 301 https://www.example.com$request_uri;
}Redirect only when the visitor's original scheme, sent by the proxy in X-Forwarded-Proto, was http.
server {
listen 80;
server_name www.example.com;
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
location / {
proxy_pass http://127.0.0.1:3000;
}
}-I asks for headers only, -L follows redirects. Each block in the output is one hop.
curl -sIL http://example.com/ | grep -iE "^(HTTP|location)"
A modern site often has three or four places that can redirect: the CDN, the hosting platform, the web server and the app. Each one is configured on its own screen, so two of them can quietly disagree about the scheme, the host or the trailing slash.
The simulator above models exactly that. Put every layer's rules in the same list and the disagreement turns into a visible cycle.
When TLS ends at a proxy or load balancer, your server only ever sees plain HTTP. A rule that says redirect anything on HTTP to HTTPS then fires on every request, including ones that were HTTPS for the visitor. Proxies send the original scheme in the X-Forwarded-Proto header, so the server should check that instead.
That message and the error code ERR_TOO_MANY_REDIRECTS describe the same thing: the site answered with redirect after redirect and the browser stopped following. Nothing on your computer is broken, although a stale cookie can be part of the loop.
The Fetch Standard, which browsers implement, returns a network error when a request's redirect count reaches 20.
The visitor connects with HTTPS, but the proxy forwards the request to your server over plain HTTP. Your server sees HTTP and redirects to HTTPS, and the cycle repeats. Cloudflare documents this exact loop for its Flexible encryption mode.
Only when a cookie is part of the loop, such as a login session that never gets stored. If the loop is in the server rules, clearing cookies changes nothing.
A page stuck in a loop never loads, so crawlers cannot read it either. Fix loops quickly and keep redirect chains short.
Related: Redirect checker, Redirect rules generator, HTTP status codes reference, Nginx 502 and other nginx errors, SSL certificate types.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.