Skip to main content

Magento 2 ERR_TOO_MANY_REDIRECTS

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· One min read
Stephan Hochdörfer
Head of IT Business Operations

A while ago when importing a staging dump to reproduce an issue locally in one of our Magento projects, I hit an "ERR_TOO_MANY_REDIRECTS" error. Magento kept redirecting me with a HTTP 302 response code.

In the past this meant, there's a problem with the domains defined in web/unsecure/base_url or web/secure/base_url. Also checking the web/cookie/cookie_domain configuration can be helpful to get rid of the error.

However, I could not figure out what the problem was and had to debug things quite deep in Magento core to identify the real problem. Apparently, in Magento you can configure the name of HTTP header to identify the protocol (HTTP or HTTPS) that a client used to connect to your load balancer.

The configuration variable in Magento for this is called web/secure/offloader_header. In this case it was set to SSL_OFFLOADED, but our local Traefik instance uses the header key X-Forwarded-Proto. Thanks to that, Magento was not able to identify that the incoming request is an actual SSL connection and kept redirecting the client (my web browser) to the configured SSL url.

After setting the configuration variable web/secure/offloader_header to X-Forwarded-Proto, clearing the Magento cache and reloading the website in my browser, things were working again.