Magento Admin Login Problem

Share

From Magento version 1.2.1 you will notice that suddenly you cannot log in to the admin panel after you have installed Magento. And this happens only when you install it locally and use http://localhost/

The reason is Magento have implemented a security check to see the domain is a valid one with dots in it. http://localhost/ hence fails as a valid domain.

There are two remedies for it –

1. Use 127.0.0.1 instead. Having dots it will qualify.

2. Modify your host file to use http://www.localhost.com instead of simple http://localhost/
      For this follow these steps if you are using Windows XP –
      a> Open file C:\WINDOWS\system32\drivers\etc\hosts (Replace C: with the drive name where your OS is installed)
      b> Add the following line at the end of the file and save it.
          127.0.0.1      www.localhost.com

Apart from the 2 above mentioned points you can also hack the Magento core a bit. But as that is not the correct way lets not discuss it 😛

Now while installing Magento, in the Configuration step, under “Web access options”, for “Base URL” use http://127.0.0.1 or http://www.localhost.com/ according to what you would be using.

If you have already installed Magento with “localhost”

Do not worry if you have already installed Magento with “localhost” as “Base URL” and your store keeps going back to http://localhost even if you enter http://www.localhost.com

Just follow these steps –

1. Open the Database
2. Open table core_config_data
3. UPDATE value of the record WHERE path = ‘web/unsecure/base_url’ from localhost to 127.0.0.1 or www.localhost.com
4. Follow the same for path = ‘web/secure/base_url’
5. Go to \var\cache and delete all folders.

Now you can use the site with www.localhost.com or 127.0.0.1

———————————————————————————-

Thanks Joseph. I skipped the second part of configuration during installation initially. Just to make it sure, I hope you were talking about the “Base Url” and not the “host” (which is actually the host of the database) in the comment.

This entry was posted in Magento, PHP and tagged , . Bookmark the permalink.
 

3 Responses to Magento Admin Login Problem

  1. Joseph Hummel says:

    modifying host is only step 1
    step 2 is when doing the install when prompted for the host you must not put localhost you must use the alternate 127.0.0.1 or whatever fits your server because it validates it when installing.

    so if you are using the installer with your browser locally in the section that asks for the databse info replace localhost with 127.0.0.1 and VOILA should work – did for me I had to figure it out myself

  2. bassgrinder says:

    Well, if you like one solution for all these, then why not try this piece of solution. There's only one piece of code block to dismiss temporarily among the Magento Core files. Details here: http://markuzweb.blogspot.com/2009/08/cant-login-to-magento-admin-panel-after.html

  3. Sumit Surai says:

    @bassgrinder :: The solution at the link you mentioned will work. But its never a good idea to change Magento core files. We should avoid that process 🙂

Leave a Reply

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

*