Home / Localhost / Localhost redirected too many times

localhost redirected you too many times (ERR_TOO_MANY_REDIRECTS)

Fix ERR_TOO_MANY_REDIRECTS on localhost: clear cookies, fix HTTP and HTTPS rules, and WordPress URL settings.

This error means the page keeps sending the browser to another address that sends it back, in a loop. The cause is usually old cookies, or two settings that disagree about http or https, or about www.

What to do, step by step

  1. Clear cookies and site data for localhost, or test in a private window. A bad cookie can cause the loop by itself.
  2. Look at the redirects: run curl -IL http://localhost and read the Location lines. You will see the loop.
  3. Find where each redirect comes from: the web server config (.htaccess, nginx), the app or CMS settings, or a plugin.
  4. Make sure only one place decides on https and on www. Remove the duplicate rule.
  5. If you use a proxy or tunnel, pass the original protocol (X-Forwarded-Proto) to the app.

Commands you can copy

Follow the redirects and print each Location
curl -IL http://localhost
WordPress: lines for wp-config.php
define('WP_HOME', 'http://localhost');
define('WP_SITEURL', 'http://localhost');

Other causes to check

WordPress: the home and site URLs differ from how you open it
Set both in wp-config.php: define('WP_HOME', 'http://localhost'); define('WP_SITEURL', 'http://localhost'); Use the address you really type, with the right port.
An HTTPS redirect on a site that has no certificate
On localhost there is usually no certificate. Remove the HTTPS redirect from .htaccess for local use, or set up a local certificate.
Behind a proxy or Docker
The app sees plain HTTP and redirects to HTTPS forever. Send the X-Forwarded-Proto header and tell the app to trust it.
A cache plugin or CDN setting
Turn the plugin off by renaming its folder, or switch off its redirect option.

Questions about Localhost redirected too many times

Why does clearing cookies fix it sometimes?
A cookie that stores a redirect or login state can send the page in circles. Removing it ends the loop.
Can .htaccess cause it?
Yes. A rule that redirects to HTTPS, or adds or removes www, fights with the same setting in your app. Keep one of them only.
What is a redirect loop?
Address A sends you to B and B sends you back to A, so the browser gives up after about 20 tries and shows this error.

Updated 2026-10-11

Config generators for this

Related pages