cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 admin - too many redirects

SOLVED

Magento 2 admin - too many redirects

After migrating version 1 to a new Magento 2 site, the admin URL is no longer working.  When I try to visit the admin URL.  I get a browser error that indicates too many redirects.  I have tried it with several browsers with similar results.

 

I have tried the following to resolve it:

 

php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

 However, this did not resolve the issue.

 

What needs to be done to get this fixed?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2 admin - too many redirects

I found the following to fix the issue.

 

the web/secure/use_in_adminhtml was set to 0 by using the following command:

php bin/magento config:show web/secure/use_in_adminhtml

However, after changing it to 1, the redirect error was still present.  I then removed the contents of the var/cache folder.  

I was then able to connect to the admin login page and login.

 

 

View solution in original post

13 REPLIES 13

Re: Magento 2 admin - too many redirects

@ubcomputers 

 

It seems browser cache/cookies are causing the issue. You just need to clear browser cache & cookies and it should work for you.

 

Please clear Magento cache too. 

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2 admin - too many redirects

Hi @ubcomputers 

 

Too many redirects on the admin console is the known issue and asked by so many users previously.

 

To resolve the issue, i would suggest you to check your secure URL parameter value in your database by running the following query - it value has to be 1 if you are using SSL on your site.

SELECT * FROM core_config_data where path like '%web/secure/use_in_adminhtml%';
 
Another issue will be cookie_domain value - check cookie_domain value from the database it has to be matched with your installed and configured domain name.
 
Another possible solution is to check into the .htaccess file is there any redirects added on this.

For more reference i would suggest you to follow the following links :
 
Hope it helps !
if issue solved,Click Kudos & Accept as Solution

Re: Magento 2 admin - too many redirects

Try this method. 

php bin/magento setup:upgrade
bin/magento config:set dev/static/sign 0
php bin/magento setup:static-content:deploy -f
php bin/magento setup:di:compile 
php bin/magento cache:flush
sudo chmod -R 0777 var/ pub/ generated/
php bin/magento indexer:reindex


 

Re: Magento 2 admin - too many redirects

I found the following to fix the issue.

 

the web/secure/use_in_adminhtml was set to 0 by using the following command:

php bin/magento config:show web/secure/use_in_adminhtml

However, after changing it to 1, the redirect error was still present.  I then removed the contents of the var/cache folder.  

I was then able to connect to the admin login page and login.

 

 

Re: Magento 2 admin - too many redirects

Place a new copy of .htaccess from a fresh Magento package and delete the cache and session folder as well. Then refresh and it should be good.

 

Or another way is,

 

In the “core_config_data” table remove the value of “web/cookie/cookie_domain” and set “web/cookie/cookie_httponly” to “0”. Clear the cache by removing the files in “var/cache”.

 

 

Re: Magento 2 admin - too many redirects

My issue was that the cookie domain in config was not set or was different from the base url

 

so when accessing admin area, the domain didn't match the cookie set domain which caused the redirect loop.

 

stores > Configuration > General > Web - Default Cookie Settings

Re: Magento 2 admin - too many redirects

I have a fresh install of 2.4.1 and none of these fixes found in this thread are working. I can see the home page for Luma in browser, but cannot access the admin page. I have verified the web/secure/use_in_adminhtml was set to 1, cleared var/cache, cleared cookies, looked into database to verify "SELECT * FROM core_config_data where path like '%web/secure/use_in_adminhtml%';", tried the method:

 

php bin/magento setup:upgrade
bin/magento config:set dev/static/sign 0
php bin/magento setup:static-content:deploy -f

 

 

I will also add that I have disabled the CAPTCHA and the 2FA. 

bin/magento module:disable Magento_TwoFactorAuth
bin/magento cache:flush

sudo bin/magento security:recaptcha:disable-for-user-login

bin/magento setup:store-config:set --use-secure 1
bin/magento setup:store-config:set --use-secure-admin 1
bin/magento cache:flush

rm -rf var/cache/* var/page_cache/* generated/code/*
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f


php bin/magento setup:di:compile
php bin/magento cache:flush
sudo chmod -R 0777 var/ pub/ generated/
php bin/magento indexer:reindex

 

and tried:
In the “core_config_data” table remove the value of “web/cookie/cookie_domain” and set “web/cookie/cookie_httponly” to “0”. Clear the cache by removing the files in “var/cache”.

absolutly nothing works. I could use some help. I wll say that 2.3.4 is working great.

Re: Magento 2 admin - too many redirects

.

Re: Magento 2 admin - too many redirects


@ubcomputers wrote:

I found the following to fix the issue.

 

the web/secure/use_in_adminhtml was set to 0 by using the following command:

php bin/magento config:show web/secure/use_in_adminhtml

However, after changing it to 1, the redirect error was still present.  I then removed the contents of the var/cache folder.  

I was then able to connect to the admin login page and login.

 

 


On a fresh install, this will return a blank response. These commands will fix that were not included in the response.

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