Skip to content

Redirect Loop or Failed Redirect

DownBad couldn’t reach the page your monitor checks, because following your site’s redirects went wrong: they go round in a loop, there are more of them than DownBad follows, or one leads somewhere DownBad can’t or won’t go. This page traces every redirect, fixes the one that’s wrong, and takes you to a closed incident.

A redirect is an answer that sends a visitor on to another address instead of showing a page. The server answers with a code such as 301 or 302, and with a Location: line in its headers (the information a server sends before the page itself) naming the new address. Browsers follow redirects without you noticing. So does a URL monitor (DownBad’s check of a web address) while its Follow Redirects setting is on, which it is unless you turned it off. A web address starts http:// for HTTP, the plain way browsers fetch pages, or https:// for HTTPS, the same with encryption.

An incident is open for one, and it shows one of these reasons:

  • Maximum number of redirects exceeded: DownBad followed five redirects in a row and was sent on again. Either the redirects go round in a loop (one address sends you to a second, and the second sends you back), or the chain is longer than five. The incident shows the failure type unknown.
  • Redirected request failed: Unsupported protocol ftp:: a redirect named an address DownBad can’t fetch, here one starting ftp:// (a way of sharing files that isn’t the web). The words after the colon say what was wrong with it: here, the protocol (the way of fetching an address, which its start names, such as https://) isn’t one DownBad uses. The incident shows the failure type unknown.
  • Refusing to follow redirect: 10.0.0.5 is not a publicly routable address (private, loopback, link-local, or reserved range). Point the monitor at a target that does not redirect to a private address.: a redirect named a private address (one that only works inside a network, such as 10.0.0.5 or localhost), and DownBad won’t follow it. The incident shows the failure type redirect.

DownBad follows at most five redirects for one check. A browser follows up to 20 before it gives up, in Chrome and in Firefox, so a chain of six to 20 redirects can load in your browser and still fail here.

If the monitor’s Follow Redirects is off, a redirect fails it in another way, on its status code (the number at the start of the server’s answer, such as 301), which Website Returns an Error Status Code covers.

It is your site, or a service in front of it. Every redirect is an answer your site sends, and anyone who follows the same redirects gets the same answers.

There are two exceptions. A chain of six to 20 redirects loads in a browser, which follows more than DownBad does: see The chain has more than five redirects. And DownBad’s check doesn’t keep cookies (small pieces of data a site asks a browser to store and send back on later visits) from one redirect to the next. A site that keeps redirecting until it gets a cookie back loops for DownBad but loads in your browser: see The site redirects until it gets a cookie back.

A loop also shows in a browser, as an error page. Chrome says the site “redirected you too many times” (Chromium’s wording), and Firefox says “The page isn’t redirecting properly” (Firefox’s wording).

To see every redirect without a terminal (the window where you type commands: Terminal on a Mac, PowerShell on Windows), enter the monitor’s URL in Redirect Checker, a free tool that, in its own words, will “check and show redirect chains” and “http headers like Status Code”. It lists each redirect, its code, and where it leads.

This command asks for your page the way DownBad’s check does, follows up to five redirects, and prints the code and the Location: line of every answer. Run it in a terminal. It only reads, and changes nothing.

It uses curl, a tool for fetching web addresses, which comes with macOS, most kinds of Linux, and every installation of Windows 10 and 11. -A sends DownBad’s user agent (the name a program gives itself to the sites it visits), -m 23 gives up after 23 seconds, the longest a DownBad check waits, and -L --max-redirs 5 follows up to five redirects. If the monitor’s HTTP Headers has a User-Agent entry, put its value in place of DownBad’s. Put the monitor’s URL, exactly as it is set, in place of https://example.com/.

The examples below are what it printed for http://wikipedia.org/, which redirects twice before its page, and for two test sites with a loop. In one, www.example.com and the bare domain example.com send visitors to each other (your domain is the name your site uses, and the bare domain is that name with nothing in front of it). In the other, one https:// address sends visitors back to itself.

Terminal window
curl -sS -m 23 -A "DownBad/1.0 (Uptime Monitor; +https://downbad.app/docs/resources/checker/)" -L --max-redirs 5 -D - -o /dev/null https://example.com/ | grep -i -E "^(HTTP|location)"

grep keeps only the lines that start HTTP or location.

If it works
HTTP/1.1 301 Moved Permanently
location: https://wikipedia.org/
HTTP/2 301
location: https://www.wikipedia.org/
HTTP/2 200
If www and the bare domain loop
HTTP/1.1 301 Moved Permanently
Location: http://www.example.com/
HTTP/1.1 301 Moved Permanently
Location: http://example.com/
HTTP/1.1 301 Moved Permanently
Location: http://www.example.com/
HTTP/1.1 301 Moved Permanently
Location: http://example.com/
HTTP/1.1 301 Moved Permanently
Location: http://www.example.com/
HTTP/1.1 301 Moved Permanently
Location: http://example.com/
curl: (47) Maximum (5) redirects followed
If the same https:// address loops
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
curl: (47) Maximum (5) redirects followed

How to read it:

The causes below run from most to least likely, so start with the first. If the incident’s reason starts Redirected request failed: or Refusing to follow redirect:, go straight to the last two.

Most fixes happen in the settings of your web server (the program that answers your site’s visitors), in the dashboard of a CDN (a service such as Cloudflare that sits in front of your site), or in your site’s own admin pages. If someone else runs the site for you, such as a hosting company or a web agency, send them the reason the incident shows, the output of Check it yourself and a link to this page.

This is the likely cause when the location: lines in Check it yourself switch between http:// and https://, or repeat the same https:// address. Usually a service in front of your site, such as a CDN or a load balancer (a service that shares visitors out between servers), connects to your server over plain HTTP. Your server, which sends every HTTP visitor on to HTTPS, sends the request back to the same https:// address, and the service passes it to your server over HTTP again. Sometimes it is the other way round: the service connects over HTTPS, and your server sends visitors back to HTTP.

  1. Run Check it yourself and note the address that repeats.

  2. If your site is behind Cloudflare, check its encryption mode. Cloudflare’s guide to redirect loops says that in Flexible mode it “sends unencrypted requests to your origin server over HTTP” (your origin server is your own server, behind Cloudflare), and that “Redirect loops will occur if your origin server automatically redirects all HTTP requests to HTTPS”. In the Cloudflare dashboard, go to SSL/TLS (its section for encryption: TLS is the encryption behind https://, and SSL its old name) and its Overview page, and choose the encryption mode Full or Full (strict) (Cloudflare’s guide to encryption modes). If the dashboard offers Automatic SSL/TLS, those two are under Custom SSL/TLS. Cloudflare says this “requires an SSL certificate configured at your origin server”, a certificate being the file a server needs to answer https:// addresses. The other fix it gives is to remove the redirect to HTTPS from your server.

  3. If your server sends HTTPS visitors back to HTTP, the same guide says that loops “will occur if your origin server automatically redirects all HTTPS requests to HTTP” in Full or Full (strict) mode, and that the fix is to “remove HTTP redirects from your origin server”. With Cloudflare’s Always Use HTTPS on, it says to “remove HTTPS redirects from your origin server or disable Always Use HTTPS”. That setting is on the Edge Certificates page under SSL/TLS (Cloudflare’s guide to Always Use HTTPS).

  4. If your site is behind Amazon CloudFront (Amazon’s CDN), which calls your own server behind it your custom origin server, or custom origin, Amazon’s guide to CloudFront redirect loops says to “require HTTPS for communication between CloudFront and your custom origin”. Edit the origin and set its protocol to HTTPS only, the setting that guide calls the origin protocol policy (CloudFront’s origin settings). The same guide says: “You must have a valid SSL/TLS certificate on your custom origin server.”

  5. If your site is behind a load balancer that handles HTTPS itself, such as Amazon’s Application Load Balancer, your server has to tell an HTTP visitor from an HTTPS one by the X-Forwarded-Proto header the load balancer adds, which, in Amazon’s words, “helps you identify the protocol (HTTP or HTTPS) that a client used to connect to your load balancer”. On Apache (a widely used web server), its guide explains that behind such a load balancer %{HTTPS} “will always report off”, and checks the header instead, with this line before the redirect:

    RewriteCond "%{HTTP:X-Forwarded-Proto}" =http [NC]

    The same guide warns about the load balancer, which it calls the upstream proxy (a service that passes visitors’ requests on to your server): “Only trust X-Forwarded-Proto if you control the upstream proxy and it overwrites the header on every request.”

    For a site on WordPress (a widely used system for building websites), see The WordPress address settings don’t match.

  6. Run Check it yourself again. It should end with HTTP/2 200 or HTTP/1.1 200 OK. Then follow Confirm DownBad sees the fix.

www and the bare domain redirect to each other

Section titled “www and the bare domain redirect to each other”

This is the likely cause when the location: lines in Check it yourself switch between www.example.com and example.com, the bare domain (your domain with nothing in front of it). Two places each send visitors to the other name: often a rule at your CDN sends one name to the other, while your web server or your site’s own settings send it back.

  1. Choose the one name your site should use. Keep the redirect that leads to it, and remove the one that leads away from it.

  2. Find the redirect that leads away from it, and remove it. Where it may be:

  3. If you changed nginx’s or Apache’s settings, reload the web server so it reads them, as SSL Certificate Expiring shows. This needs sudo, a command that runs another as the server’s administrator and asks for your password.

  4. Run Check it yourself again, for both names. Each should end with a 200 after one redirect at most. Then follow Confirm DownBad sees the fix.

The WordPress address settings don’t match

Section titled “The WordPress address settings don’t match”

This is the likely cause when your site runs on WordPress (a widely used system for building websites), and the loop involves www. or https://. WordPress has two settings for its own address. When they don’t match the address visitors are sent to, or when WordPress can’t tell that a service in front of it handles HTTPS, it can keep sending visitors back.

  1. In WordPress, open Settings and then General, and look at WordPress Address (URL) and Site Address (URL). WordPress’s guide says “The “Site Address (URL)” setting is the address you want people to type in their browser to reach your WordPress blog”. Set both to the address your site really uses, the one your other redirects lead to, with the same https:// or http:// and the same www. or none, and save.

  2. If the loop keeps you out of the admin pages, set the two addresses in the file wp-config.php on your server instead, as the same guide shows, with your address in place of https://example.com. This changes a file on the server. The guide warns that “You won’t be able to edit them on the General settings page anymore when using this method”.

    define( 'WP_HOME', 'https://example.com' );
    define( 'WP_SITEURL', 'https://example.com' );
  3. If WordPress sits behind a CDN or load balancer that handles HTTPS for it, WordPress’s guide to HTTPS says that behind such a service, its HTTPS settings “will initially send any requests into an infinite redirect loop”. Add the lines it gives to wp-config.php, which changes a file on your server. They make WordPress read the X-Forwarded-Proto header the service adds:

    if( strpos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false )
    $_SERVER['HTTPS'] = 'on';
  4. Run Check it yourself again. It should end with the code 200. Then follow Confirm DownBad sees the fix.

Section titled “The site redirects until it gets a cookie back”

This is the likely cause when Check it yourself shows the same location: again and again, but the page loads in your browser. Some sites send every new visitor a cookie and a redirect back to the same page, and show the page only once the cookie comes back. Browsers keep cookies. DownBad’s check doesn’t, so it never gets past the redirect.

To test for it, run the command from Check it yourself again with -b "" added. curl’s manual says that with an empty name, “curl activates the cookie engine without any cookies”, so it sends back the cookies the site gives it, and that “No cookies are written to that file”, so it saves nothing.

Terminal window
curl -sS -m 23 -A "DownBad/1.0 (Uptime Monitor; +https://downbad.app/docs/resources/checker/)" -L --max-redirs 5 -b "" -D - -o /dev/null https://example.com/ | grep -i -E "^(HTTP|location)"
If the cookie is the cause
HTTP/1.1 302 Moved Temporarily
Location: /
HTTP/1.1 200 OK
If it still loops
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/1.1 301 Moved Permanently
Location: https://example.com/
curl: (47) Maximum (5) redirects followed

Without a terminal, use Chrome. Close all Incognito windows (Chrome’s private windows), then open a new one: Google’s guide to Incognito says that Chrome then “starts a separate browsing session”, and that after a session ends it “doesn’t retain site data”, so the new window has none of the site’s cookies. Open Chrome’s DevTools (its tools for looking inside a page) with F12, or Cmd + Option + I on a Mac, as Chrome’s guide shows. Select its Network panel and tick Preserve log, which in Chrome’s words keeps “requests across page loads”. Then open the monitor’s URL in that window, select the first request for that URL in the list, and open its Headers tab (Chrome’s guide to headers). If its Response Headers have a set-cookie line and a location that points back to the same address, and the page loads after it, the site waits for a cookie.

If it still loops, the cookie isn’t the cause: go back to the causes above.

  1. Find what sets the cookie and redirects: a plugin (an add-on that gives a site an extra feature) or setting in your site, or a security service in front of it. Change it so a visitor without the cookie still gets the page, or so it leaves visitors with the monitor’s user agent alone: DownBad’s, DownBad/1.0 (Uptime Monitor; +https://downbad.app/docs/resources/checker/), unless the monitor’s HTTP Headers sets another. Or point the monitor at a page on your site that doesn’t need the cookie: open the monitor from Monitors in DownBad’s sidebar, select Edit on its Configuration card, change its URL, and save.

  2. Run Check it yourself again, without -b "". It should end with a 200. Then follow Confirm DownBad sees the fix.

This is the likely cause when Check it yourself shows six redirects to different addresses, none of them repeating, and then curl stops. DownBad follows at most five, while a browser follows up to 20, so the page can load in your browser and still fail here.

  1. Open the monitor’s URL in your browser, and copy the address in the address bar once the page has loaded. That is where the chain ends.

  2. Point the monitor there: open the monitor from Monitors in DownBad’s sidebar, select Edit on its Configuration card, put the final address in its URL, and save.

  3. To shorten the chain for everyone, make each old address redirect straight to the final one, in one step: with return 301 on nginx, a Redirect line on Apache, or a redirect rule on Cloudflare.

  4. Run Check it yourself again, with the monitor’s new URL. It should end with a 200 within five redirects. Then follow Confirm DownBad sees the fix.

A redirect leads somewhere DownBad can’t follow

Section titled “A redirect leads somewhere DownBad can’t follow”

This is the cause when the incident’s reason starts Redirected request failed:. A redirect named an address DownBad can’t fetch, such as one starting ftp:// (a way of sharing files that isn’t the web), and the words after the colon say what was wrong with it. DownBad follows redirects only to addresses starting http:// or https://.

  1. Find the redirect: in Check it yourself, the last location: line names the address it led to.

  2. Change that redirect so it leads to a valid http:// or https:// address, wherever it is set: a return 301 on nginx, a Redirect line on Apache, a redirect rule on Cloudflare, or the plugin or setting in your site that made it.

  3. Run Check it yourself again. It should end with the code 200. Then follow Confirm DownBad sees the fix.

A redirect leads to a private or internal address

Section titled “A redirect leads to a private or internal address”

This is the cause when the incident’s reason starts Refusing to follow redirect:. A redirect sent DownBad to an address that only works inside a network: localhost or a name ending .local or .internal, a name with no dot in it, a private address such as 10.0.0.5 or 192.168.1.10, or a name that resolves to a private address (the reason then reads <name> resolves to <address>). The reason names it. DownBad refuses on purpose. A check that went wherever a site pointed it could be made to reach DownBad’s own systems, the attack known as server-side request forgery. In it, in the words of OWASP (a foundation that publishes guides on web security), “the attacker can abuse functionality on the server to read or update internal resources”.

Your site most likely sends the redirect by mistake. A common one is an app whose own address setting still names the address it was built on, such as http://localhost:3000.

  1. Find the redirect: the incident’s reason names the address, and in Check it yourself the last location: line shows it.

  2. Change the setting that produces it to your site’s public address: the app’s own address setting, the address settings of WordPress as in The WordPress address settings don’t match, or the redirect in your web server’s settings, on nginx or Apache.

  3. Run Check it yourself again. No location: line should name a private address or a name that resolves to one, and it should end with a 200. Then follow Confirm DownBad sees the fix.

  1. Fix the cause first. A check that still fails while you work only adds to the time the incident takes to close.

  2. Open the incident and press Test Now. DownBad checks again within a few seconds instead of waiting for the next scheduled check.

  3. Wait a minute, then reload the incident page, which doesn’t update by itself. The incident closes by itself once enough checks in a row pass. You can’t close an incident by hand.

How many passing checks it takes. While an incident is open, DownBad checks less often after repeated failures. This is called back-off. Each failed check adds one step of back-off, up to 14. Each passing check takes one step away and asks for the next check straight away. When no steps are left, one more passing check closes the incident. So after a steady outage it takes one more passing check than there were failed checks while the incident was open, counting the one that opened it, and never more than 15.

These are the defaults. The monitor’s notification profile can change them for each monitor type under Backoff Config, and its settings are the ones that count: Recovery is how many passing checks in a row, with no back-off left, close the incident (2 by default, counting the check that takes the last step away), and Start after, Rate and Max interval decide when back-off starts and how far it goes. If the profile changes them, the step counts above and the waits below change with them.

How long that takes. After you press Test Now, those passing checks run back to back, a few seconds apart, so the incident usually closes within a minute. It takes longer when checks are slow to finish, such as a page that takes several seconds to load.

If you don’t press Test Now, the first passing check waits for the next scheduled one. With the default settings, from the third failed check on, DownBad waits 5 more minutes for each failure, up to an hour more than the monitor’s usual interval:

Monitor checks everyAfter 1 or 2 failed checksAfter 3After 6After 14 or more
1 minute1 minute6 minutes21 minutes61 minutes
5 minutes5 minutes10 minutes25 minutes65 minutes
1 hour1 hour1 hour 5 minutes1 hour 20 minutes2 hours
1 day1 day1 day 5 minutes1 day 20 minutes1 day 1 hour

Before you ask for help, collect:

  • the link to the incident, and the reason it shows, word for word
  • the output of the command in Check it yourself, and when you ran it
  • whether the page loads in your browser
  • the name of any service in front of your site, such as a CDN or load balancer, and its setting for HTTPS, such as Cloudflare’s encryption mode

Then send all of it to us through Contact Us.