Redirect Loops: How to Find and Fix Them

Redirect Loops: How to Find and Fix Them

3 min read

redirects · redirect-loop · https · cdn · tools

Authors

PandaONE Team

Diagnose ERR_TOO_MANY_REDIRECTS with a hop-by-hop redirect trace, fix HTTPS/www and CDN loop patterns, and know when redirects become a security issue.

ERR_TOO_MANY_REDIRECTS. Users cannot load the site. Cookies and HSTS make the browser look guilty — usually two layers both “fix” HTTP vs HTTPS and send you in circles.

A loop means hop N returns to a URL already in the chain. Trace hops with a redirect checker instead of clicking in a tab that already cached bad 301s.

Find the loop in minutes

  1. Open the redirect checker.
  2. Paste the exact URL users hit (http vs https, www vs apex).
  3. Read each hop: status and Location.
  4. Mark the first URL that repeats — that closes the loop.
  5. Fix the rule emitting the bad Location, re-trace.

Status codes: how to check 301 redirects.

Common loop patterns

HTTP ↔ HTTPS fighting

  • Origin forces HTTPS
  • CDN terminates TLS but forwards http:// host headers
  • App sees “not HTTPS” and redirects again

Fix: One layer owns HTTPS enforcement. Pass X-Forwarded-Proto (or equivalent) once and trust it.

www ↔ apex fighting

  • Apex → www, www → apex
  • Often DNS ALIAS plus app host rules

Fix: Pick canonical host. One side 301s; the other serves. Align CDN “always HTTPS” with that choice.

CDN vs origin SSL mode

Cloudflare-style Flexible SSL while origin also redirects to HTTPS: browser → CDN HTTP → origin HTTPS → CDN HTTP again.

Fix: End-to-end HTTPS (Full / Full strict or vendor equivalent) and valid origin cert. Check the leaf with SSL certificate check.

  • / → /en → / when cookies disagree
  • Trailing-slash bounce /app ↔ /app/
  • Login redirect back to protected URL with SameSite / domain cookie mistakes

Fix: Log server-side branch decisions. Test with the redirect checker or incognito without cookies.

How to fix systematically

  1. Write the intended canonical URL (scheme + host + path).
  2. Disable competing redirects in app or CDN or LB until one layer owns policy.
  3. Re-enable a single 301/308 to canonical.
  4. Clear site cookies when testing auth/locale loops.
  5. Re-run the redirect checker from http:// and https:// entry points.

Flatten permanent chains when you can. Loops are the extreme case of messy chains.

Availability vs security

IssueUser impactSecurity angle
Redirect loopSite unusableAvailability / SEO
Open redirectUser lands off-sitePhishing / token theft pivots
Mixed http in chainWarnings, cookie bugsDowngrade risk

Loops are configuration. Open redirects are attacker-influenced destinations — different triage bucket.

Prevention checklist

  • Document canonical host in runbooks
  • Synthetic check: fail if hop count > N or a URL repeats
  • Review CDN SSL mode on every origin cert change
  • After migrations test apex, www, bare HTTP, deep links

Incident response when production is looping

  1. Post canonical URL in the incident channel so fixes do not fight each other
  2. Revert the last CDN/app redirect change before stacking more rules
  3. Redirect checker confirms loop gone before all-clear
  4. Purge CDN cache if edge rules cached mid-incident
  5. HSTS-pinned users retry canonical HTTPS after DNS/TLS fix

Loop after cert renewal? Check SANs and origin SSL mode — how to check an SSL certificate.

Staging rehearsals

Match CDN SSL mode on staging to production before cutover. Flexible SSL plus copied apex rules invent many loops. Five-minute redirect trace beats an hour of war-room archaeology.

FAQ

Browser loops but curl does not?
Cookies, HSTS, cached 301s. Clear site data or read checker hop list; verify with clean client after fix.

302 loop vs 301 loop?
Both break users. 301s cache longer in clients.

Can SEO tools cause this?
They report loops. Your rules or CDN/origin mismatch cause them.

How many hops is too many?
Prefer one permanent hop. Four+ adds latency and hides mistakes.

Summary

Trace with the redirect checker, find the repeated URL, and remove duplicate HTTPS or host policy between CDN and origin. Flexible SSL plus origin HTTPS redirect is the usual CDN footgun. Loops are availability; open redirects are a separate security class.

Featured on ScrollLaunchFeatured on CodeHype