ERR_TOO_MANY_REDIRECTS in WordPress: after a migration or with Cloudflare
· The AYT team · 6 min read

ERR_TOO_MANY_REDIRECTS ("This page isn't working: site.com redirected you too many times") appears when the site sends the browser from one address to another in a circle until the browser gives up. In WordPress, the loop nearly always comes from two rules that contradict each other: the site address saved in WordPress, the server's rule (HTTP to HTTPS, www or no www) or the SSL setting in Cloudflare. The fix is to find the wrong rule and remove it.
First test: cookies
Open the site in a private window. If it works there, your browser is holding on to an old redirect or cookie: clear the site's cookies and data in your browser settings. If the error shows up in the private window too, the problem is on the server, so read on.
See the ERR_TOO_MANY_REDIRECTS loop with one command
The command below, run in Terminal on macOS or Linux, follows the redirects and shows every step (on Windows, run curl.exe -sIL https://site.com and look for the Location lines):
curl -sIL --max-redirs 10 https://site.com | grep -iE '^(HTTP|location)'
The output looks something like this:
HTTP/2 301
location: https://www.site.com/
HTTP/2 301
location: https://site.com/
HTTP/2 301
location: https://www.site.com/
Here one rule sends visitors to www and another sends them back to the address without www. If the alternation is between http:// and https://, the problem is HTTPS (causes 2 and 3). Without a command line, open your browser's developer tools (F12), go to the Network tab, tick "Preserve log" and reload the page.
Cause 1: the site address in WordPress
WordPress redirects every visitor to the address saved in its settings (Settings → General, "WordPress Address" and "Site Address", which are the siteurl and home options in the wp_options table). If that says https://www.site.com while the server or Cloudflare sends www to the bare domain, you get the loop shown above.
To fix it when you can't get into wp-admin, put the correct address in wp-config.php, above the line /* That's all, stop editing! */:
define( 'WP_HOME', 'https://site.com' );
define( 'WP_SITEURL', 'https://site.com' );
The constants override the database values without changing them. Once the site works, correct the values in wp_options too (in phpMyAdmin or under Settings → General) and you can remove the constants. Pick one version, with www or without, and make the server, Cloudflare and WordPress all use the same one.
Cause 2: Cloudflare in "Flexible" SSL mode
In Flexible mode, Cloudflare receives the visitor over HTTPS but requests the page from your server over plain, unencrypted HTTP. If the server or WordPress forces HTTPS, it answers with a redirect to https://. Cloudflare passes it to the browser, the browser comes back over HTTPS, and the cycle repeats.
Cloudflare's documentation is clear: if your server redirects HTTP to HTTPS, don't use Flexible. The fix:
- Make sure the server has a valid SSL certificate for the domain (including
www). - In Cloudflare, under SSL/TLS, choose Full (strict) mode.
- Turn on "Always Use HTTPS" in Cloudflare, so the redirect to HTTPS happens at Cloudflare.
Full mode (without "strict") also stops the loop, but it doesn't check the server's certificate. Cloudflare recommends Full (strict) when the server has a valid certificate. For a step-by-step Cloudflare setup, see the Cloudflare guide for WordPress.
Cause 3: WordPress doesn't know the visitor is on HTTPS
Behind a proxy or load balancer that terminates HTTPS, PHP sees the request arriving over HTTP. The is_ssl() function returns false, and WordPress (or an SSL plugin) keeps redirecting to HTTPS. This often shows up only in wp-admin, when wp-config.php contains FORCE_SSL_ADMIN.
If the proxy sends the X-Forwarded-Proto header, add this to wp-config.php, above the line /* That's all, stop editing! */:
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
$_SERVER['HTTPS'] = 'on';
}
Use this code only if you know a proxy sits in front of the site. A server that receives HTTPS traffic directly doesn't need it.
Cause 4: two rules doing the same job
A redirect or SSL plugin (forcing HTTPS or www) plus the same kind of rule on the server or in Cloudflare, but with a different version of the address: each sends visitors its own way. To check, deactivate the plugins. Without wp-admin access, rename the wp-content/plugins folder to plugins-off in the File Manager or over FTP. If the site comes back, restore the folder name and reactivate the plugins one by one until you find the culprit.
Check the server's rules too: return 301 blocks in nginx, or RewriteRule lines in .htaccess on Apache. For redirects done right, see how to set up a 301 redirect in WordPress.
After a migration
A loop that appears right after moving the site usually combines several of the causes above:
- the address in
wp_optionsis still the old one (another domain,http://orwww), and the URL replacement missed it; - the new server forces HTTPS, but the SSL certificate isn't issued yet or Cloudflare is still on Flexible;
- a cache plugin or Redis is holding the old redirect or address in memory: clear the cache after every change.
If the move is still in progress, go through the steps of the guide to moving a WordPress site one at a time.
Frequently asked questions
Why does only wp-admin show the error?
Most often cause 3: FORCE_SSL_ADMIN requires HTTPS, but WordPress doesn't see that the request came over HTTPS. More rarely, an old login cookie; try a private window.
Does deleting the .htaccess file help?
Only on Apache, and only if the loop comes from a rule written there. Make a copy of the file first. On nginx, .htaccess isn't read at all.
On AYT hosting
On AYT, the SSL certificate (Let's Encrypt) is issued and renewed automatically for the domain and www, so you can use Full (strict) mode in Cloudflare. You can move the DNS zone to your own Cloudflare account straight from the panel. The web server is nginx, so a .htaccess left over from your previous host no longer causes redirects; add your own redirects from the Redirects page, and replace old addresses in the database with the WordPress Toolkit's search and replace. If you are coming from another host, the move is free on paid plans and we do it for you, with the site online throughout.
