Skip to content

Fix “Too many redirects” error after enabling Cloudflare Proxy

New Course Coming Soon:

Get Really Good at Git

I had an Astro site on Railway and since I manage my DNS using Cloudflare, I figured I could take advantage of everything Cloudflare offers if I proxy the requests through it, instead of just using it as a DNS.

I changed my CNAME record that points to the Railway app from “DNS only” to “Proxied” but the app was not served any more by the browser, with an error saying “Too many redirects”.

The reason is that by default Cloudflare in proxy mode sends unencrypted HTTP request to the server, behind the scenes, but the app on Railway was configured to use HTTPS automatically and this caused an infinite loop of redirects.

The problem was well documented on Cloudflare’s docs.

The solution was to go in the SSL/TLS settings on that domain on Cloudflare, and switch the encryption mode from Flexible (the default) to Full.

Then everything worked as expected.

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!

Here is how can I help you: