62

Often, when a script has a redirect loop we get an error in Google Chrome that says

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

How many redirects are too many?

Dennis
  • 14,264
  • 2
  • 48
  • 57
Tarang
  • 75,157
  • 39
  • 215
  • 276

3 Answers3

72

Google Chrome 17.0.963.56 allows a maximum of 20 redirects, as tested with this PHP script:

<?php
    $redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : 0;
    header("Location: redirects.php?redirect=" . ($redirect + 1));
?>

Chrome aborts with error 310 when trying to open redirects.php?redirect=21, which means that the first 20 redirects were successful.

Dennis
  • 14,264
  • 2
  • 48
  • 57
  • For people inexperienced with PHP, is there a quick & easy way to run this script that you could share? – Adam S Mar 22 '17 at 21:46
  • @AdamS If PHP is installed and in your path, you can use the [built-in web server](http://php.net/manual/en/features.commandline.webserver.php). Save this script as `redirects.php` in your working directory, run `php -S localhost:8080`, and then navigate to http://localhost:8080/redirects.php with your browser of choice. – NReilingh Oct 13 '17 at 18:43
58

Tested on Win 7 64bit

  • Chrome 64bit Version: 49 105.0.5195.127 (Official Build), (19*X) redirects
  • Chrome Canary 64bit, Version: 49 108.0.5337.0 (Official Build), (19*X) redirects
    3 retries sum up to 57 redirects
  • Firefox 32-bit version: 43 105.0.1, 20 redirects
  • Firefox 64-bit version: 43 105.0.1, 20 redirects
    • Firefox 64-bit 67.0.4, endless loop!
  • Opera version: 28, 90.0.4480.84 (19*3) redirects
  • Safari version: 5.1.7, 16 redirects
  • IE version: 8 11 redirects via webpagetest.org
  • IE version: 9 121 redirects via webpagetest.org
  • IE version: 10 121 redirects via webpagetest.org
  • IE version: 11.48.17134.0 110 redirects
  • Microsoft Edge version: 42.17134.1.0 20 redirects
  • Microsoft Edge version: 105.0.1343.53 (19 * X) redirects
    5 retries sum up to 95 redirects
  • Google Nexus 5, Samsung Galaxy S4 ⇄ S9, Galaxy Tab 4, 19 redirects


Panos Kalatzantonakis
  • 12,525
  • 8
  • 64
  • 85
2

Chrome and Firefox out of the box is 20, Internet Explorer is 10, I couldn't tell you on Opera or Safari

Anthony Shaw
  • 8,146
  • 4
  • 44
  • 62
  • 1
    *Internet Explorer is 10.* What version? Because I've tested with IE 9 and the maximum was `110`. – Dennis Feb 21 '12 at 20:49
  • I would have said IE9 intially, but its possible we experienced it with IE8. I can't imagine that Microsoft would have changed the limit to 110 in IE9 when other browsers aren't configured even close to that. Wonder if you've had something modify the registry setting that affects redirects – Anthony Shaw Feb 21 '12 at 21:19
  • 2
    As far as I know, the default setting can be modified only in `[HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\Internet Settings\MaxHttpRedirects`. I checked and neither value does exist. – Dennis Feb 21 '12 at 21:29
  • interesting... I cannot find any of the documentation that we found on it before, but a couple years ago we were having issues with some redirects in a authentication module that we had written and it would work fine in FF/Chrome, but would bomb out in IE everytime. We found that on certain occasions, it was doing 12-13 redirects and IE was crapping out – Anthony Shaw Feb 22 '12 at 00:42
  • 1
    I couldn't find another machine with IE 9, but I discovered [WebPagetest.org](http://www.webpagetest.org). The results are fairly strange: Only `10` redirects for IE 7 and 8, but `110` for IE 9 and `102` for IE 6. Also, IE 9 refreshes after every 10th redirect and IE 6 refreshes after the 100th. – Dennis Feb 22 '12 at 01:51
  • Do you have an external url that you are using to test? I have a couple VM's that I've used in the past for testing IE compatibility with default installs of each version of IE. I'd like to see the results from a real browser if you don't mind, out of pure curiosity – Anthony Shaw Feb 22 '12 at 13:26
  • Cool, I'll fire up my VM's this evening and post back the results that I find as well. – Anthony Shaw Feb 22 '12 at 14:00
  • Is there anyway to ignore this? Or clear the redirect loop count? – Jay Jan 15 '15 at 13:09