Admin URL frontname is set to "admin" but on hitting the URL http://www.example.com/admin it redirects to localhost/admin

Working on localhost

web/secure/base_url and web/unsecure/base_url is set to http://localhost/sitename

Using Magento 2.1.8

  • check web/unsecure/base_url and web/secure/base_url path value in data base core_config_data table. Dec 10, 2019 at 12:31
  • so let me know on which server you working. share your server URL is it localhost or else? then I can tell you exact solution. Dec 10, 2019 at 12:36
  • it is localhost. web/unsecure/base_url and web/secure/base_url path is set to localhost/sitename
    – GenZ Dev
    Dec 10, 2019 at 12:42

2 Answers 2


Check your Baseurl and Baseurl secure  

Change From :-


To :-

Then Run This Command :-

sudo php bin/magento cache:flush

sudo php bin/magento cache:clean
  • Finally this worked. Can you explain why this happens?
    – GenZ Dev
    Dec 10, 2019 at 13:16

First change from



second, after doing this remove var/cache folder.

  • did the changes but it is still redirecting to localhost/admin
    – GenZ Dev
    Dec 10, 2019 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.