Cloudflare ERR_TOO_MANY_REDIRECTS: Causes and How to Fix It

Quick Answer: How to Fix Cloudflare ERR_TOO_MANY_REDIRECTS

The ERR_TOO_MANY_REDIRECTS error occurs when your web browser gets stuck in an infinite redirect loop between Cloudflare's edge proxy servers and your origin web server. In the vast majority of cases, this issue is caused by setting Cloudflare's SSL/TLS encryption mode to Flexible while your origin server is already configured to automatically redirect HTTP requests to HTTPS.

Conceptual network routing loop diagram representing infinite browser redirects and server configuration errors.

To fix the issue immediately:

  1. Log in to your Cloudflare Dashboard and select your domain.
  2. Navigate to SSL/TLS > Overview.
  3. Change the encryption mode from Flexible to Full or Full (Strict).
  4. Clear your browser cache or open an incognito window to verify site access.

If you encounter certificate errors such as ERR_SSL_VERSION_OR_CIPHER_MISMATCH or Error 526 after changing this setting, ensure your origin web server has an active SSL/TLS certificate installed.

Understanding the Infinite Redirect Loop

When an end user requests your site over HTTPS, Cloudflare intercepts the request at its edge network. How Cloudflare handles the connection to your origin web server depends entirely on your SSL/TLS encryption setting.

  • Flexible Mode: Cloudflare connects to your browser securely via HTTPS, but connects to your origin web server over unencrypted HTTP (port 80).
  • Full Mode: Cloudflare connects to your browser via HTTPS and connects to your origin server over encrypted HTTPS (port 443), allowing self-signed origin certificates.
  • Full (Strict) Mode: Cloudflare connects to your browser over HTTPS and requires a valid, unencrypted, trusted SSL certificate (or Cloudflare Origin CA certificate) on the origin server over port 443.

When Cloudflare is set to Flexible mode, it sends an unencrypted HTTP request to your origin web server. If your origin web server (Nginx, Apache, IIS, or an application framework like WordPress or Laravel) has a rewrite rule configured to force HTTPS traffic, it inspects the incoming HTTP request and responds with a 301 Moved Permanently or 302 Found redirect pointing to the https:// version of the URL.

Cloudflare receives this redirect and passes it back to the client browser. The browser follows the redirect instructions and requests the https:// URL from Cloudflare again. Cloudflare receives the new request and once again connects to your origin over unencrypted HTTP. This sequence repeats endlessly until the browser breaks the loop and displays the ERR_TOO_MANY_REDIRECTS error screen.

Common Causes of Cloudflare Redirect Loops

While an active Flexible SSL mode on an HTTPS-enforcing origin is the primary trigger, several related misconfigurations can cause identical redirect loops:

  • Flexible Mode SSL Misconfiguration: As detailed above, pairing Flexible mode with origin-side HTTPS enforcement causes an immediate loop.
  • Application URL Protocols: Content management systems like WordPress store absolute URLs in their settings. If the siteurl or home options are set to http:// while Cloudflare or your origin forces https://, an internal application loop occurs.
  • Conflicting Page Rules or Redirect Rules: Having an active Cloudflare Page Rule (such as "Always Use HTTPS") while your origin server software also performs forced canonical URL rewrites or port redirects can create edge-level loops.
  • Double Redirect Chains in Web Server Configs: Misconfigured rules in .htaccess (Apache) or nginx.conf (Nginx) that strip or add www prefixes simultaneously with SSL redirects can cause circular routing.

Diagnostic Steps: Verifying Origin Redirect Behavior

Before modifying server files or Cloudflare rules, diagnose exactly where the redirect is originating using command-line tools like curl.

1. Test the Origin Directly (Bypassing Cloudflare)

To confirm whether your origin web server forces an HTTP-to-HTTPS redirect, query your origin server's IP address directly, bypassing Cloudflare's proxy network completely. According to Cloudflare's official troubleshooting documentation, you can use the --connect-to flag in curl to send requests directly to the origin server IP:

curl -ksvo /dev/null http://example.com --connect-to ::192.0.2.1

Replace example.com with your domain and 192.0.2.1 with your actual origin server IP address.

Inspect the output HTTP response header:

  • If the origin returns HTTP/1.1 301 Moved Permanently or HTTP/1.1 302 Found with a Location: https://example.com/ header, your origin enforces HTTPS. Flexible mode cannot be used.
  • If the origin returns HTTP/1.1 200 OK, your origin serves plain HTTP without forcing a secure connection.

2. Check Response Headers for Edge Loops

You can also test the proxy response using curl to inspect the redirect location headers returned through Cloudflare:

curl -I L https://example.com

If the terminal outputs dozens of identical 301 or 302 locations pointing back and forth between HTTP and HTTPS protocols, an edge-to-origin loop is verified.

Step-by-Step Fixes

Fix 1: Switch Cloudflare SSL/TLS to Full or Full (Strict)

If your origin web server has an SSL certificate installed, updating your Cloudflare SSL setting is the fastest and most secure resolution.

  1. Log in to the Cloudflare Dashboard.
  2. Select your website.
  3. Click SSL/TLS in the left sidebar navigation.
  4. On the Overview tab, select Full or Full (Strict).

Security Note: Selecting Full (Strict) requires a valid SSL certificate on your origin server issued by a public Certificate Authority or a Cloudflare Origin CA certificate. If your origin lacks a valid certificate when switching to Full (Strict), users will see an Error 526 (Invalid SSL Certificate) screen. If your server uses a self-signed certificate, select Full mode instead.

Fix 2: Correct WordPress Site URL Settings

If you run a WordPress site, mismatched URL schemes in your database will force internal redirects. If you encounter issues accessing your admin panel or saving settings, you can check server connectivity or database states; for database-related errors, refer to our guide on fixing WordPress Error Establishing a Database Connection.

To fix WordPress site URLs directly in your wp-config.php file:

  1. Connect to your server via SSH or FTP.
  2. Open the wp-config.php file located in your site's root directory.
  3. Add the following lines above the line that says /* That's all, stop editing! Happy publishing. */:

define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://example.com');

Ensure both defined constants utilize the https:// scheme. Save the file and clear your WordPress caching plugin.

Fix 3: Adjust Web Server Rewrite Rules

If you must keep Cloudflare on Flexible mode temporarily (for example, while renewing an expired origin certificate), you must remove the HTTP-to-HTTPS redirect rules on your origin server to prevent the loop.

For Apache (.htaccess):

Locate and temporarily comment out (add # at the beginning of the line) any forced HTTPS rewrite rules, such as:

# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

For Nginx (nginx.conf / site block):

Inspect your server configuration for blocks that force redirects on port 80:

server {
    listen 80;
    server_name example.com;
    # Comment out forced redirects while under Flexible mode:
    # return 301 https://$host$request_uri;
}

Caution: Removing HTTPS redirects on your origin server exposes unencrypted HTTP traffic between Cloudflare and your server. This should only be used as a temporary diagnostic step until an SSL certificate is installed on the origin server so you can switch Cloudflare to Full (Strict) mode.

Fix 4: Audit Cloudflare Page Rules and Edge Rules

Conflicting rule combinations within Cloudflare can also cause loop conditions:

  1. In the Cloudflare Dashboard, navigate to Rules > Page Rules.
  2. Check if you have custom Forwarding URL (301/302) rules that target HTTP requests while Always Use HTTPS is enabled under Edge Certificates.
  3. Disable or adjust conflicting rules to ensure traffic resolves to a single canonical HTTPS address.

Verification and Post-Fix Checks

After applying your fixes, confirm that the redirect loop is resolved:

  • Open a browser terminal or developer console (F12) and inspect the Network tab while requesting your home page. Confirm that your browser receives a single 200 OK response status without falling into repeating 301 or 302 chains.
  • Use an incognito/private browsing tab to bypass local browser redirect caching. Browsers aggressively cache 301 Moved Permanently headers; clearing site data is essential after making server configuration updates.
  • If your site handles external API traffic or webhook deliveries and fails after server updates, review our guide on WooCommerce Webhooks Automatically Disabled After Delivery Failures for tips on diagnosing edge connectivity issues.

When to Contact Support

If you have updated your SSL mode to Full (Strict), verified your site settings, and cleared your cache but continue to experience redirect loops:

  • Contact Hosting Support: Ask your host to verify whether an internal load balancer, reverse proxy, or firewall rule (such as AWS ALB or server-level Nginx proxy) is stripping the X-Forwarded-Proto header before traffic reaches your application.
  • Contact Cloudflare Support: If diagnostic cURL tests directly to your origin IP return a 200 OK status over HTTP, but edge proxying produces continuous redirects despite Page Rules being disabled, open a support request through your Cloudflare account console.

Sources & References

Comments

Popular posts from this blog

Cloudflare Error 522 (Connection Timed Out): Causes and How to Fix It

WooCommerce Checkout Stuck Loading: Causes and How to Fix It

Shopify Checkout Not Working: Causes, Diagnostics, and Fixes