ERR_TOO_MANY_REDIRECTS
ID: networking/too-many-redirects
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
The client followed too many HTTP redirects (301/302/307/308) without reaching a final response. This creates an infinite redirect loop, typically caused by conflicting redirect rules between the web server, application, CDN, and load balancer.
genericWorkarounds
-
90% success Trace the redirect chain and identify the loop, then fix conflicting rules
1. Trace the redirect chain: curl -v -L --max-redirs 10 https://example.com 2>&1 | grep -i 'location:' 2. Identify the loop pattern (e.g., HTTP -> HTTPS -> HTTP, www -> non-www -> www) 3. Check web server config for conflicting redirects: - nginx: look for competing return 301 and rewrite rules - Apache: check .htaccess, httpd.conf for conflicting RewriteRule directives 4. Check if CDN (Cloudflare, etc.) adds an HTTPS redirect that conflicts with the server's redirect 5. Ensure the redirect target URL is the canonical final destination 6. Clear browser cookies that might contain redirect-triggering session data
-
88% success Fix the HTTP/HTTPS or www/non-www redirect at a single layer
1. Decide on a single canonical URL form: https://www.example.com or https://example.com 2. Implement the redirect at ONLY one layer (web server OR CDN OR application, not multiple) 3. For nginx: server { listen 80; return 301 https://$host$request_uri; } (only this one redirect rule for HTTP->HTTPS) 4. If using Cloudflare, set SSL mode to 'Full (Strict)' to prevent the origin and CDN from both redirecting 5. Remove duplicate redirect rules from .htaccess, application middleware, and CDN page rules 6. Test: curl -I http://example.com and curl -I https://example.com to verify single redirects
Dead Ends
Common approaches that don't work:
-
Increase the maximum redirect limit in the HTTP client
95% fail
The redirects form an infinite loop (A -> B -> A -> B...). Increasing the limit from 20 to 100 just means the client follows 100 redirects before failing instead of 20. The loop never terminates because the same URLs keep redirecting to each other.
-
Disable all redirects in the client as a workaround
85% fail
Disabling redirect following means the client receives the first 301/302 response and stops. This does not render the intended page and breaks normal redirect flows. The redirect loop is a server-side configuration issue that must be fixed on the server.