Lovable custom domain with Cloudflare: fix "too many redirects" (ERR_TOO_MANY_REDIRECTS)
Updated · by Zane
What a redirect loop is
Your browser asks for a page, gets told to go somewhere else, goes there, and gets told to go back. After a handful of rounds it gives up and shows ERR_TOO_MANY_REDIRECTS or "the page isn't redirecting properly". Cloudflare's documentation describes it as visitors getting stuck in a redirect loop, and lists three common causes: the SSL/TLS encryption mode, settings on the Edge Certificates page, and conflicting redirect rules.
If your problem is a domain that never goes live in Lovable, or a site that shows another error, start with Lovable custom domain not working. This guide is for the case where the domain does load into a loop, which only happens once Cloudflare is in the path.
What Lovable says about Cloudflare
Lovable's documentation gives two ways to use a domain managed at Cloudflare.
- The default. Set the A record and the TXT record Lovable gives you to DNS only (grey cloud), not Proxied (orange cloud). The documentation attributes Cloudflare errors 1001 and 1003 to the proxy and tells you to switch the records to grey.
- Proxy mode. When connecting the domain, open Advanced and enable Uses Cloudflare or similar proxy. Lovable then asks for a CNAME record pointing to your project's lovable.app address, which replaces the A record, and it does not require the TXT record. The documentation adds that you are then responsible for configuring and maintaining the proxy, and that Lovable does not configure, validate or monitor it.
I could not find a page in Lovable's documentation that names the redirect loop or says which Cloudflare SSL/TLS mode to choose in proxy mode. Treat what follows about modes as Cloudflare's documented behavior, applied to Lovable, not as a Lovable instruction.
Why Flexible mode loops
Cloudflare's SSL/TLS encryption mode controls two separate connections: visitor to Cloudflare, and Cloudflare to the server behind it. In Flexible mode the first one is encrypted and the second one is plain http. Cloudflare's documentation says redirect loops occur if the server behind it automatically redirects all http requests to https.
Walk through it. The visitor asks for https. Cloudflare asks your server over http. The server answers "use https instead". Cloudflare passes that on, the visitor comes back over https, and it starts again. Cloudflare's fix is either to remove the https redirect from the server, which is not something Lovable's documentation lets you control, or to use Full or higher.
Whether Lovable's servers redirect http to https is not something its documentation states, so I cannot say that this is the exact cause on your site. It is the first thing to rule out, because it is a one-click change and the loop is a textbook match. The reverse also exists: Cloudflare says Full and Full (strict) loop if the server redirects https requests to http, which is unusual.
Step 1: look at the actual chain
You do not need to guess. This prints each redirect and where it goes:
# Follow the redirects and print each hop (use your own domain)
curl -sIL --max-redirs 6 http://yourdomain.com | grep -i -E "^(HTTP|location)"
# Same for www
curl -sIL --max-redirs 6 https://www.yourdomain.com | grep -i -E "^(HTTP|location)"If the lines repeat, you have a loop and the Location values show who is sending whom. Look for http turning into https and back, or the plain domain and www pointing at each other. No terminal? Open the browser's developer tools on the Network tab with Preserve log on and reload.
Step 2: check the SSL/TLS mode
- In the Cloudflare dashboard, pick your domain and go to SSL/TLS, then Overview.
- Note the encryption mode: Off, Flexible, Full, Full (strict), or Automatic.
- If it is Flexible and the records are orange cloud, change it to Full or Full (strict), wait a minute, and retest in a private window.
Cloudflare strongly recommends Full or Full (strict) wherever possible. Cloudflare's documentation also describes an Automatic mode, still rolling out, that picks the safest mode it can detect and never moves you to a less secure one. If the mode label confuses you, the choice you make here affects only the proxied (orange) records.
If the records are grey cloud
Grey cloud means Cloudflare only answers DNS questions and does not touch the traffic, according to Cloudflare's documentation on proxy status. The SSL/TLS mode then has no effect on that record. A loop with grey records is more likely a redirect rule, covered below.
Step 3: Always Use HTTPS and HSTS
Under SSL/TLS, then Edge Certificates, Cloudflare has an Always Use HTTPS switch that redirects every http request to https at its edge. That is safe when the server behind it does not redirect back. Cloudflare's documentation names two combinations that loop: a server that redirects https to http, and, with HSTS, an encryption mode set to Off. If you recently turned these on, turn them off one at a time and retest.
Step 4: redirect rules and the primary domain
Cloudflare's documentation lists conflicting redirect rules and Page Rules as the third cause: for example, one rule sends a.example.com to b.example.com and another sends it back. Open Rules in Cloudflare and look at every redirect.
This is where Lovable matters. Its documentation says that one connected domain is the primary, the first custom domain you add becomes primary automatically, and every other connected domain redirects to it with a temporary 302. Suppose Lovable's primary is the plain domain, so www goes to the plain domain, and you also made a Cloudflare rule that sends the plain domain to www. Each one undoes the other. That specific pairing is my reading of the two documented behaviors, not a case Lovable or Cloudflare documents, but the curl check in step 1 will show it straight away.
- Pick one direction, plain domain or www, and make Lovable's primary domain the same one. In Lovable that is Project, Settings, Domains, the three dots, Set as primary.
- Delete the Cloudflare rule for the opposite direction, since Lovable already redirects.
- Lovable's documentation says it cannot do a permanent 301 between its own connected domains. If you need a 301, a Cloudflare rule is the place, but only in the same direction as the primary.
Step 5: choose one clean setup and stay with it
Option A: grey cloud
- In Cloudflare, go to DNS, then Records.
- For the A record and any www record that point to Lovable, click the orange cloud so it turns grey.
- Wait a few minutes, then retest.
Option B: keep the proxy
- In Lovable, disconnect the domain, then connect it again with Advanced, then Uses Cloudflare or similar proxy.
- Add the CNAME record Lovable shows, once for each address you connect. For the plain domain, Cloudflare's documentation says CNAME flattening is what allows a CNAME at the root.
- Remove the old A and TXT records for the same host so they do not conflict.
- Set the SSL/TLS mode to Full or Full (strict), and make sure no redirect rule opposes the primary domain.
Test the fix
- The curl command ends with a 200 and does not repeat.
- http, https, the plain domain and www all end on the one primary address.
- A private window and your phone on mobile data both load the site.
- The Domains screen in Lovable still shows Live, and you can sign in on the new address.
If Lovable shows Connection issue after a change, its documentation says the warning under the domain explains what it found, and says not to change DNS based on a Check failed status alone. For the DNS records themselves, see the main domain guide. The same grey-cloud rule appears in Replit custom domain not working.
FAQ
Does Lovable say anything about ERR_TOO_MANY_REDIRECTS?
Not in the domain documentation I could find. Lovable documents Cloudflare errors 1001 and 1003, the grey-cloud setup, and a proxy option with a CNAME record. The redirect loop itself is explained in Cloudflare's own documentation, which is why this guide uses both.
Should I just turn the orange cloud off?
It is the setup Lovable's documentation tells you to use by default, and it is the quickest way to stop a loop caused by the proxy. You lose what Cloudflare's proxy adds, such as its firewall and caching. If you need those, use Lovable's proxy option instead of the default records.
Why does only one browser or device show the loop?
Your browser can remember redirects and, if HSTS is on, remember to use https only. Test in a private window and from your phone on mobile data before changing settings. Cloudflare's documentation lists HSTS as one of the settings that can take part in a loop.
Is Flexible mode always wrong?
No. Cloudflare says to choose Flexible when your origin has no certificate. It loops only when the origin also redirects every http request to https. Cloudflare recommends Full or Full (strict) wherever possible.
Checklist
Still stuck?
Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.
Related guides
- Bolt.new Stripe webhook not working after deploying to Netlify (404 or no upgrade)
- Lovable custom domain not working: stuck pending, no SSL, or www fails
- Lovable email verification not working: signup confirmation emails not arriving
- Lovable Google sign in showing redirect_uri_mismatch or an unverified app warning
- Base44 custom domain stuck on Pending verification
- Base44 payment succeeded, but the customer was not upgraded
- Lovable Stripe checkout: "Edge Function returned a non-2xx status code"
- Lovable password reset link not working or sending users to the wrong page
- Replit custom domain not working: stuck on Verifying or showing a blank page
- Is your Supabase data public? A two-minute RLS check
- Blank white page after publishing your AI-built app
- “No such price” when going live: Stripe test and live mode mixed up
- Stripe payment succeeded but the user is still on the Free plan
- Subscription cancelled in Stripe but the user still has the paid plan
- Stripe webhook signature verification failed (400): causes and fix
- Login sends users to localhost or the preview URL after publishing
- Supabase update returns no error but nothing changes