Too Many Redirects: Find the Loop, Then Break It

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.

The loops behind most too many redirects errors
LoopHow it happensFix
HTTPS behind a proxyThe proxy talks plain HTTP to the server, which redirects to HTTPS againRedirect on X-Forwarded-Proto, or redirect at the proxy only
www versus bare domainOne layer adds www, another removes itChoose one host and redirect to it in one place
Cookie or login loopThe login page sends you to the account page, which sends you back because the cookie never stuckCheck the cookie's Domain, Path and Secure flags
Trailing slashOne rule adds a slash, another strips itPick 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 loop simulator

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

  1. http://example.com/
  2. https://example.com/
  3. https://www.example.com/
  4. https://example.com/

Loop: the chain returns to https://example.com/, so the browser stops with too many redirects.

Config that redirects exactly once

nginx terminating TLS itself

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;
}

nginx behind a proxy that ends TLS

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;
    }
}

See every hop from the command line

-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)"

Why loops happen in layers

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.

The proxy scheme problem

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.

How it works

  1. List every redirect you know of: server config, hosting dashboard, CDN rules, app code.
  2. Write them one per line as full addresses joined by ->.
  3. Enter the address that fails in the browser and read the hop list.
  4. Remove or change the rule that sends the chain back to an address it already visited.

Tips

Frequently asked questions

What does redirected you too many times mean?

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.

How many redirects does a browser follow?

The Fetch Standard, which browsers implement, returns a network error when a request's redirect count reaches 20.

Why does forcing HTTPS cause a loop behind a proxy or CDN?

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.

Does clearing cookies fix too many redirects?

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.

Can a redirect loop hurt SEO?

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.

More in Guides

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.

Product

Who It's For

Features

Resources

Company

View Sitemap