ERR_TOO_MANY_REDIRECTS (redirect loop)
This error means the browser was bounced between URLs until it gave up. The classic cause is a redirect loop between HTTP and HTTPS, very often a Cloudflare SSL setting fighting your server config.
- About the error
- Why do I see this error
- Solution
- Fix Cloudflare SSL mode
- Trust the proxy's protocol header
- Check your nginx redirect
- Diagnose the loop
- If it isn't your website
About the error
The browser shows ERR_TOO_MANY_REDIRECTS (Chrome) or "The page isn't redirecting properly" (Firefox). It means a URL redirected to another URL that redirected back, forming a loop. After a handful of hops the browser stops to avoid looping forever.
Why do I see this error
The overwhelmingly common cause is an HTTP ↔ HTTPS loop, and the most common trigger of that is Cloudflare's SSL mode set to "Flexible":
- Cloudflare talks to your server over plain HTTP.
- Your server (or app) redirects all HTTP to HTTPS.
- Cloudflare receives that redirect, requests again over HTTP, gets redirected again, forever.
Other causes: an app forcing HTTPS while a proxy already terminates TLS, a misconfigured www ↔ non-www redirect, or two redirect rules pointing at each other.
Solution
Fix Cloudflare SSL mode
If you use Cloudflare, set the SSL/TLS encryption mode to Full or Full (strict), never Flexible. Flexible is the single biggest cause of this loop for sites behind Cloudflare. Full means Cloudflare connects to your origin over HTTPS, which matches your server redirecting to HTTPS. See an A+ grade SSL using Cloudflare.
Trust the proxy's protocol header
When TLS is terminated by a proxy or load balancer, your app sees the request as plain HTTP and redirects to HTTPS, even though the visitor is already on HTTPS. Tell the app to trust the forwarded protocol. In Laravel, configure trusted proxies in bootstrap/app.php:
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: '*', headers:
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO
);
})
Check your nginx redirect
A correct HTTP→HTTPS redirect redirects only plain HTTP, and the HTTPS server block must not redirect again:
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
# serve the site here, do NOT redirect to https again
}
nginx can also loop internally, without the browser ever seeing a redirect, that's the rewrite or internal redirection cycle error in the nginx error log.
Diagnose the loop
Follow the redirect chain with curl to see exactly where it loops:
curl -sIL https://example.com | grep -i location
If you see the same two URLs alternating, you've found your loop.
If it isn't your website
When you hit this on a site you don't control, the fix is on your end: delete that site's cookies and reload. A stale or corrupt session cookie is the usual culprit, and an incognito window (which starts with no cookies) is the fastest way to confirm it. If the page loads in incognito, clear the cookies in your normal window.