ERR_TOO_MANY_REDIRECTS after adding Cloudflare
Last verified:
The fix
The browser loops as soon as the custom domain is proxied. Cloudflare's Flexible SSL talks to the host over HTTP, and the host redirects that HTTP request back to HTTPS.
- 1
Confirm the loop is the domain, not the app
In the network log, the first response for
https://example.com/is a redirect, and it keeps bouncing. Response headers includecf-rayorserver: cloudflarewhen the proxy is in front. If the only URLs in the loop are/loginand the app, use the login redirect page. This one started when the custom domain was proxied. - 2
Set the encryption mode to Full (strict)
In the Cloudflare dashboard open SSL/TLS, then Overview, and set the encryption mode to Full (strict). Cloudflare's too-many-redirects page says Flexible plus an origin HTTPS redirect is fixed by removing that origin redirect or by setting the mode to Full or higher. Full (strict) checks the origin certificate. Use it when the host already serves HTTPS, which Vercel and Netlify do. Full encrypts to the origin without that certificate check. Their Full (strict) page says a certificate that fails the checks can produce error 526, which is a different failure from this loop.
SSL/TLS → Overview → Full (strict) - 3
If it still loops, separate the other Cloudflare rules
The same Cloudflare page documents more loops. Always Use HTTPS redirects
httptohttpsat the edge, and loops if the origin then redirects HTTPS back to HTTP. HSTS loops in that same origin case, or if the encryption mode is Off. Two redirect rules or Page Rules that send the host to each other also loop. Turn those conflicts off one at a time. Leave Always Use HTTPS on when the mode is Full (strict) and the origin is not sending people back to HTTP. - 4
Retry in a private window
A permanent redirect can stay in the browser after the mode is fixed. Open a private window, or another browser, and request the apex and
wwwonce. The first response should be 200, or a single redirect to the canonical host, not a chain that returns to the same URL.
Why it happens
Cloudflare's SSL troubleshooting page says ERR_TOO_MANY_REDIRECTS, and Firefox's The page isn’t redirecting properly, show up after a domain is added and the visitor is stuck in a redirect loop. One cause they document is the encryption mode. Flexible means Cloudflare connects to the origin over HTTP. If the origin redirects every HTTP request to HTTPS, Cloudflare fetches HTTP again, the origin redirects again, and the browser stops with too many redirects.
Their Flexible mode page says not to use Flexible when the origin forces HTTPS that way, and to use Full or Full (strict) instead. Vercel, Netlify, and many shared hosts already redirect HTTP to HTTPS and present a certificate. Full (strict) is the mode Cloudflare says to prefer when that certificate is unexpired, trusted by a public CA or issued by Cloudflare Origin CA, and the name matches the hostname. A loop that only alternates /login and the app, with no Cloudflare in front, is the auth redirect page.
The next error you'll probably hit
Once this is fixed, the usual follow-up is ERR_TOO_MANY_REDIRECTS on login. ERR_TOO_MANY_REDIRECTS on login means the guard and the login page redirect to each other. Exclude the sign-in route and read the session from one place.
Prompt to paste back into your AI tool
Paste this above the error.
The deployed site shows ERR_TOO_MANY_REDIRECTS after I put the custom domain behind Cloudflare. It worked on the host URL before the proxy. Do not turn off the host's HTTP to HTTPS redirect. Do not set the Cloudflare encryption mode to Off. Do not debug the login middleware if the bare domain already loops. 1. Check for cf-ray or server: cloudflare, and say whether every path loops or only /login. 2. If the whole domain loops, tell me to set SSL/TLS → Overview to Full (strict) when the host already has HTTPS (Vercel, Netlify, or a host with its own certificate). Flexible is what loops against an HTTP-to-HTTPS redirect. 3. If it still loops, point at Always Use HTTPS, HSTS, or two redirect rules, using Cloudflare's too-many-redirects page. Do not rewrite the app.
Common questions
+The preview URL works and only the custom domain loops. Is the app code wrong?
The preview host is not going through this Cloudflare zone. Flexible SSL in front of a host that redirects HTTP to HTTPS is enough to loop the custom domain while the preview stays up. Set the encryption mode to Full (strict) and retry in a private window.
+I set Full (strict) and now I see error 526. Is that the same bug?
526 means Cloudflare could not validate the origin certificate under Full (strict). The redirect loop was the Flexible mode. A 526 means the certificate is missing, expired, or the hostname does not match. That is the certificate on the host, not another redirect rule.
Related errors
- ERR_TOO_MANY_REDIRECTS on loginERR_TOO_MANY_REDIRECTS on login means the guard and the login page redirect to each other. Exclude the sign-in route and read the session from one place.Cursorv0BoltAuthNext.jsOct 14, 2026
- Error 400: redirect_uri_mismatchGoogle rejected the OAuth request because the redirect_uri it received is not one of the Authorized redirect URIs on that OAuth client. The deployed domain and the callback URL are different strings.CursorLovableBoltAuthSupabaseNov 11, 2026
- 404 on refresh of a client routeA 404 on refresh means the Vite app works from /, then a reload of /dashboard misses index.html. Rewrite unknown paths to index.html on the host.CursorLovableBoltReactViteOct 16, 2026