Magento 2 Admin Error ERR_TOO_MANY_REDIRECTS

Posted on Tags ,

Recently I had to deploy one newly build Magento 2 site to its server for which there was no info what has been installed or what is the infrastructure (the normal case where they don’t follow your requirements and are not giving much info).

After the deploy the Admin area was not working, it was in a Redirect loop (ERR_TOO_MANY_REDIRECTS). As usual, you can check the config, the DB if you forgot something, then StackOverflow where you can find a lot of fixes for this, like this one, setting your configs to

php bin/magento config:sensitive:set web/secure/base_url
php bin/magento config:sensitive:set web/secure/base_link_url
php bin/magento config:set web/secure/use_in_adminhtml 1
php bin/magento cache:clean

But might not fix the redirect loop.

The problem is that your server setup is maybe behind a proxy or a load balancer but he does not provide HTTPS or HTTPS_X_FORWARDED_PROTO variables to the server configs.

If you dump $_SERVER and you cannot find HTTPS or HTTPS_X_FORWARDED_PROTO keys in the array, then just add this to your .htaccess file in the root directory, not the public directory:

SetEnv HTTPS "on"

One thought on “Magento 2 Admin Error ERR_TOO_MANY_REDIRECTS”

  1. I was working on the changes for this from last 3 hours. Your answer worked like a charm !! Thanks for the helpful post.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.