Fix ERR_TOO_MANY_REDIRECTS with Cloudflare
Fix too many redirects with Cloudflare: why
In Flexible mode Cloudflare connects to your server over plain HTTP. Your server sees an HTTP request, answers with a redirect to HTTPS, Cloudflare follows it over HTTP again, and the browser eventually gives up with ERR_TOO_MANY_REDIRECTS.
Quick diagnosis
curl -sIL https://example.com | grep -iE "^(HTTP|location)"If the same location repeats, you have a loop. Then check the Cloudflare SSL/TLS mode and any redirect rules, in this order:
| Check | Where | Looks wrong when |
|---|---|---|
| SSL/TLS mode | Cloudflare dashboard | Set to Flexible while the origin redirects to HTTPS |
| Redirect or page rules | Cloudflare Rules | Two rules send traffic back and forth between www and non-www |
| Server redirect | Nginx, Apache, .htaccess | Redirects to HTTPS without knowing the visitor already used HTTPS |
| CMS site URL | WordPress settings | Site URL still uses http or the wrong host |
Fix too many redirects with Cloudflare: Full (strict)
- Install a valid certificate on the origin. Issue a free one at TryFreeSSL or use a Cloudflare Origin CA certificate.
- In Cloudflare, open SSL/TLS and select Full (strict).
- Clear your browser cookies for the site and retry in a private window.
- Purge the Cloudflare cache if the old redirect was cached.
If you must stay on Flexible for now
Let the origin trust the header Cloudflare sends instead of redirecting every HTTP request. For WordPress, add this above the "stop editing" line in wp-config.php:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}For Nginx, redirect only when the forwarded protocol is not HTTPS:
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}Treat this as a stopgap. Flexible still leaves the second leg unencrypted.
Other redirect sources to rule out
Check for a plugin that forces HTTPS while the site URL says HTTP, a canonical www rule fighting a Cloudflare rule, and a redirect inside a CDN or caching plugin. To build one clean permanent redirect, use the HTTPS Redirect Generator and remove the duplicates. Confirm the final chain with the Live SSL Checker.
A short test routine after the fix
After you change anything, test the four URL variants: http://example.com, http://www.example.com, https://example.com and https://www.example.com. Exactly one should return 200 and the other three should send a single 301 to it. If any variant needs more than one hop, find the rule that causes the extra step.
Also test a deep URL with a query string, not just the home page, because some redirect rules drop the path or parameters. Finally, test from a second network or a phone, since a cached redirect in your own browser can hide that the problem is fixed or still there.
Related reading: the Cloudflare SSL setup guide, other HTTPS failures and the free Cloudflare certificate route.
Frequently Asked Questions
Is the redirect loop an SSL certificate problem?
Usually not. It is a mismatch between the Cloudflare mode and the redirect rules on your server.
Will Full (strict) break my site?
It can show error 526 if the origin certificate is expired or does not match the hostname. Fix the certificate first, then switch.
Why does it work in one browser but not another?
Cached redirects and cookies differ. Test in a private window or with curl.
Do I need to clear the Cloudflare cache?
Purge it if you changed redirect behavior and still see the old response.
Can I keep Flexible mode and stop the loop?
Only by removing the redirect on your server, which leaves the visitor to origin hop in plain http. That trades a visible loop for an invisible security hole, so fix the certificate instead.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.