Find and break the redirect loop on your website
ERR_
Where redirect loops come from
The CDN and server disagree about HTTPS
The CDN accepts the visitor's HTTPS request but reaches your server over plain HTTP, and your server answers every HTTP request with a redirect to HTTPS. The CDN hands that redirect back, and the browser asks for the same HTTPS address again.
Two layers pick different hosts
One rule sends www to the bare domain while another, at a different layer, sends the bare domain to www. Each looks right on its own; together they loop.
The app's stored address disagrees
An app or content management system that stores its own address and redirects anything that doesn't match it will fight a server rule that redirects the other way, such as to a different host or protocol.
An app behind a proxy can't see HTTPS
When a proxy or load balancer handles HTTPS, the app behind it receives plain HTTP. An app set to force HTTPS then redirects every request, even ones that arrived over HTTPS, unless it reads the protocol the proxy passes along.
A redirect that depends on a cookie
A sign-in or language redirect that checks for a cookie loops when the cookie never sticks, for example because it's set for a different domain. That's why the loop can hit some visitors and not others.
Chromium stops after 20 redirects, the limit the Fetch standard sets and url_
Trace the loop with curl
# Follow the redirects from yoursite.com and print each status and Location
curl -sSIL --max-redirs 10 https://yoursite.com/ | grep -iE '^(HTTP|location)'
# Ask your server directly over HTTP, the way a CDN that connects over HTTP does
# (replace 203.0.113.10 with your server's own IP address)
curl -sSI --resolve yoursite.com:80:203.0.113.10 http://yoursite.com/ | grep -iE '^(HTTP|location)'
Read the trace
Each
HTTP/line is one response and eachlocationline is where it sends the browser next. In a loop the same addresses repeat until curl stops withMaximum (10) redirects followed. The pair that alternates tells you where to look: http and https point to the protocol, www and the bare domain to the host, and a sign-in or language path to a cookie. If an https address redirects to itself, a CDN or proxy in front is probably reaching your server over plain HTTP, and the second command checks that. curl's manual explains--max-redirsand--resolve.If the second command shows your server sending plain HTTP to HTTPS, and your CDN connects to it over HTTP, that pair is the loop. Have the CDN connect over HTTPS, or have the app trust the protocol the proxy reports in the X-Forwarded-Proto header, rather than dropping the redirect. The HTTP to HTTPS and www redirect guides, linked below, cover each redirect on its own.
How to fix a redirect loop
- List every place that redirectsCheck your CDN's redirect and HTTPS settings, your web server's configuration files and your app's address setting. A loop needs at least two of them.
- Give each redirect one ownerLet a single layer handle the HTTP to HTTPS redirect and the www choice, and remove the matching rules everywhere else. One owner can't disagree with itself.
- Make the app agree with that choiceSet the app's stored address to the exact final URL, with https and the host you chose, so it never redirects away from it.
- Test with curl, then in a fresh browser windowRun the trace again until it ends on a 200. Your own browser may still replay an old permanent redirect or cookie, so check in a private window too.
Frequently asked questions
Why does the loop continue in my browser after the fix?
Your browser may still hold a cached permanent redirect or an old cookie. RFC 9110 lets clients cache a 301 unless headers say otherwise, and curl starts fresh every time. Clear the site's data in the browser or test in a private window.
How many redirects does Chrome follow?
Chrome stops after 20, the limit the Fetch standard sets for browsers. curl follows up to 50 by default, which is why the trace above sets --max-redirs 10 to stop sooner.
Why do only some visitors see the error?
A loop that depends on a cookie or on being signed in reaches only the visitors in that state, and a cached redirect can keep looping for someone who visited before the fix. A loop between your CDN and server usually hits everyone.
Check the redirects that can loop
- Website reliabilityHear about it when your site goes down, not days later from a customer.
- HTTP to HTTPS redirectSend HTTP requests to their HTTPS destination and avoid conflicting redirect rules.
- www and non-www redirectChoose www or non-www and keep redirects, canonical tags and certificates in step.
- RedirectsChoose the right redirect for a move and remove unnecessary steps to the destination.