Skip to content
  1. LuzineDebug
  2. Web, HTML & CSS
  3. This page isn’t working
Web, HTML & CSS Intermediate ≈ 15 min to fix

Fix ERR_TOO_MANY_REDIRECTS "redirected you too many times" (redirect loop)

Error message
This page isn’t working
example.com redirected you too many times.
Try deleting your cookies.
ERR_TOO_MANY_REDIRECTS
  • net::ERR_TOO_MANY_REDIRECTS
  • The page isn’t redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
  • Safari Can’t Open the Page. Too many redirects occurred trying to open “https://example.com”.
  • curl: (47) Maximum (50) redirects followed
  • Ce site vous a redirigé à de trop nombreuses reprises. ERR_TOO_MANY_REDIRECTS
In short

The server redirects the page to a URL that in turn redirects back to the first one, forever. The number one cause is Cloudflare in "Flexible" SSL mode with a server that forces HTTPS: switch Cloudflare to "Full (strict)". Otherwise, look for two conflicting rules (HTTP/HTTPS, www/non-www, login) with curl -IL.

Be the first to confirm this fix

What this error means

A redirect (a 301, 302, 307 or 308 code with a Location header) tells the browser to fetch the page somewhere else. Browsers follow about twenty redirects at most, then give up with this error. A loop forms when two layers disagree: for example, the proxy talks HTTP to the server, the server thinks the visit is HTTP and redirects to HTTPS, the browser comes back over HTTPS, the proxy talks HTTP again… The same pattern exists between www and non-www, or between a protected page and a login page that itself requires being logged in.

Common causes

  1. Cloudflare in "Flexible" SSL: Cloudflare contacts your server over HTTP, your server (or WordPress, Laravel, .htaccess) redirects to HTTPS, and so on.
  2. Proxy or load balancer not recognised: the application does not read X-Forwarded-Proto and always thinks it runs over HTTP.
  3. Conflicting www and non-www: the server redirects to www, the CMS (WordPress site address) redirects to the non-www version.
  4. Authentication loop: the login page is itself protected by the auth middleware, or a session/cookie is never stored (wrong cookie domain or secure flag).
  5. Cookies or a cached 301: the configuration is fixed but the browser replays an old permanent redirect.

Step-by-step fix

  1. See the redirect chain

    curl shows each hop: the loop is obvious (two URLs alternating). Also test in a private window to rule out cache and cookies.

    bash
    curl -sIL --max-redirs 10 http://example.com | grep -iE "^(HTTP|location)"
  2. Cloudflare: switch to Full (strict)

    In the Cloudflare dashboard > SSL/TLS > Overview, choose "Full (strict)". You need a valid certificate on your server (Let’s Encrypt or a Cloudflare origin certificate). Avoid "Flexible": traffic between Cloudflare and your server stays unencrypted.

  3. Make the app recognise the proxy HTTPS

    Laravel 11+: trust the proxy (limit it to its IPs if the server is reachable directly). WordPress: add the block to wp-config.php, before the require_once ABSPATH . 'wp-settings.php'; line.

    php
    // Laravel: bootstrap/app.php
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->trustProxies(at: '*');
    })
    
    // WordPress: wp-config.php
    if (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https') {
        $_SERVER['HTTPS'] = 'on';
    }
  4. One single canonical redirect rule

    Pick one final URL (for example https://example.com) and redirect everything else to it in one hop, in one place. Then set the same address in the CMS (WP_HOME, WP_SITEURL) or in APP_URL.

    nginx
    server {
        listen 80;
        server_name example.com www.example.com;
        return 301 https://example.com$request_uri;
    }
    
    server {
        listen 443 ssl;
        server_name www.example.com;
        ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        return 301 https://example.com$request_uri;
    }
  5. Check the login routes

    The login route must not be protected by the auth middleware. In Laravel, it belongs to the guest group. Also check SESSION_DOMAIN and SESSION_SECURE_COOKIE: a cookie the browser rejects sends you back to the login page forever.

    bash
    php artisan route:list --path=login -v
  6. Clear the site cookies and cache

    In Chrome: DevTools > Application > Storage > Clear site data, or the icon left of the address > Site settings > Delete data. Since 301 redirects are cached, always retest in a private window after a fix.

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Handle the HTTP to HTTPS redirect at one level only (Cloudflare "Always Use HTTPS" or the web server), not in three layers at once.
  • Use 302 redirects while testing and switch to 301 once the configuration is validated: a wrong 301 stays cached for visitors.
  • After each change, check the full chain with curl -IL for http://, https://, with and without www.

Frequently asked questions

Is deleting cookies enough?

Only if the loop comes from a corrupted cookie or an old cached redirect. If curl -IL also shows the loop, the problem is server-side and all your visitors see it.

Why right after enabling Cloudflare?

Cloudflare is often set to "Flexible" SSL by default: it contacts your server over HTTP, and your force-HTTPS rule sends the request back to HTTPS in a loop. Switch to "Full (strict)".

How do I unlock WordPress if I can no longer reach the admin?

Define WP_HOME and WP_SITEURL in wp-config.php with the right URL, or fix them with wp option update home and wp option update siteurl (WP-CLI).

Useful tools for this error

More Web, HTML & CSS errors

All Web, HTML & CSS errors →