Magento cannot log into admin

49

I experienced a problem just after my Magento install where the page would simply redirect back to the login without displaying an error message.  I’d login using the user credentials I just created during the install and I also tried using the default user “admin” with password “123123″ .  The trick was that I was installing on localhost and for some reason a cookie was not being set for the session.  I have other sites requiring a cookie on localhost, but Magento seems to have a problem with it.

The solution is to add the following line to your hosts file so you can access your localhost as www.localhost.com.
C:Windows\System32\drivers\etc\hosts (edit this file in notepad)
127.0.0.1 magento.localhost.com www.localhost.com
Also worth mentioning, if you need to reset a password manually in the database use the following:

UPDATE admin_user SET password=MD5(‘mypassword’) WHERE username=‘admin’;

If none of the above works, install the browser Opera and use it. Opera seems to work out of the box whereas IE, Firefox, and Google Chrome do not.

Posted in: Magento, Uncategorized
Tags:

This article has 49 comments

  1. RD 02/16/2009, 5:03 am:

    This worked perfectly! Thanks!

  2. Albert 03/02/2009, 9:08 pm:

    thanks for that helped

    • jan 04/12/2010, 12:47 pm:

      Yess, it works!

  3. Monica Olinescu 03/16/2009, 8:55 am:

    Thanks! This worked like a charm.
    This problem seems to be happening with 1.2.1 and 1.2.1.2.

    For osx and Linux users: modify /etc/hosts as indicated in the post, but make sure you do not overwrite the entry that says

    127.0.0.1 localhost

    because that entry is used when booting up the system.
    Just add your entry after this line.

  4. Steven 03/16/2009, 9:45 pm:

    I had this same problem but I use a Mac. Any idea how this fix would apply to an Apple user? Thanks

  5. Aabid Hussain 03/22/2009, 1:47 am:

    Thanks

    the procedure is correct for resetting the password but the correct syntax is like this:

    UPDATE admin_user SET password=MD5(‘newpassword’) WHERE username=’oldusername’

    and u do not need to do any thing with
    “C:\Windows\System32\drivers\etc ” file.

  6. tony 03/30/2009, 5:49 pm:

    Thanks Nick,

    That localhost change fixed my magento right up… I owe you a beer!

    cheers,
    Tony

  7. William 04/01/2009, 10:35 pm:

    thanks a lot for the help!!!problem fixed

  8. jon 04/18/2009, 11:39 pm:

    I just tried v1.3.1 and I did the same thing above.
    Somehow, it is still failure. Is there any change again in etc/hosts file?

    Thanks guys!

  9. jon 04/18/2009, 11:49 pm:

    Hi again,

    My mistake. I should also change the url, from http://localhost/magento/index.php to http://www.localhost.com/magento/index.php

    It works now. Thanks!

  10. Rajasekar 04/23/2009, 11:04 am:

    Thank you for your solution. it worked great

  11. Jeet 05/22/2009, 8:38 am:

    great it worked !! U rock man .

  12. Peter Howitt 06/02/2009, 4:07 pm:

    No need to change anything after 2 wasted hours! all you have to do on local host is use opera as your browser and it stores the cookie :)

    That is the url: http://localhost:8888/magento/index.php/admin/

    works fine on mac in Mamp as long as you use opera to access it

    • Anna Ivanov 01/11/2011, 4:32 pm:

      You’re right! I use Mac as well and tried every possible suggestion, and nothing seemed to work. I just tested it on Opera and Chrome, and it works on both.
      Does not work on Firefox for me, but Chrome is good enough!
      Thanks for the advice.

  13. prabhat 06/09/2009, 2:24 am:

    hi,
    it works when i just browse http://www.localhost.com/magento/ but if i tried to put http://www.localhost.com/magento/admin it automatically redirects to http://localhost/magento/admin and username password doesn’t work. Do I need to do some extra settings?

    • james 09/04/2009, 1:55 pm:

      Don’t forget to delete all of the files in /var/cache and /var/session

      This was happening to me, and after I deleted the cache it was rebuilt correctly and I could login fine.

      I set up a virtual host for my install after trying the 127.0.0.1 trick, but you probably just need to delete the cache.

      Hope that helps,

      James

      • Fred Blauer 02/25/2010, 3:10 pm:

        I tried everything else to no avail.
        Opera worked for me!
        Also, Clearing the var/cache and var/sessions worked for me, as James suggested. I didn’t see this anywhere else!

        Many thanks.

      • sanjeev 02/01/2011, 5:08 pm:

        Thank you so much

        Great !

        It’s really appreciated

        Again Thanks

  14. Raj 06/23/2009, 5:01 am:

    I tried all of above and works for me only for the server machine where the magento is installed. however if I try to access the magento from other pcs in the LAN it gives me the same problem. I am not even able to perform normal operations on the store front. Please help.

  15. Raj 06/23/2009, 5:08 am:

    Hi,

    I am not able to access and do operations on my LAN through the normal storefront as well. E.g. If I try to add the item in the shopping cart instead of adding the item, it just give me the message that there is no item in the shopping cart. If I use the installation on the server machine where Magento is running the storefront works okay. So it is just that if I install Magento on One Machine and try to access it through another machine on lan, it give me this trouble of accessing the admin login as well as normal store operations.
    Please help.

  16. Raj 06/23/2009, 5:12 am:

    When I am testing more, I am unable to create a customer account also from one PC on to the server where the magento is installed. Please help.

  17. Francois 06/25/2009, 4:38 am:

    “hi,
    it works when i just browse http://www.localhost.com/magento/ but if i tried to put http://www.localhost.com/magento/admin it automatically redirects to http://localhost/magento/admin and username password doesn’t work. Do I need to do some extra settings?”

    This is happening for me as well. Going to 127.0.0.1 or http://www.localhost.com used to work, but I just updated to the latest version, and admin login just redirect to localhost every time with invalid u/p.

    Anyone has a fix?

  18. Nobody 08/04/2009, 1:27 pm:

    Hey Folks,
    There is an other way to fix that problem http://www.magentocommerce.com/boards/viewthread/42823/

  19. magento 08/11/2009, 4:29 am:

    cannot login admin magento on localhost.
    could you help me at this time?

  20. Kim Delmote 08/21/2009, 4:20 am:

    Changing host names can be annoying for other people as they will also have to add the hostname change to see the Magento site.

    You can also use your
    – IP (if it is fixed),
    – 127.0.0.1 – For local uses
    – Computer Name (Doesn’t allow you by default so just use locahost and change it in the config data table later- See below)

    If you ever need to change this just go to the magento database core_config_data and change the 2 URLS of magento

  21. Ramesh 09/08/2009, 6:02 am:

    Hi All,

    Everything works fine with Opera.

  22. Gabe 12/23/2009, 5:16 pm:

    Wow, that is the craziest thing. I tried everything, but the only thing that worked was using Opera. Weird! Thanks!

  23. Ajay 01/25/2010, 2:39 pm:

    Hi there,

    After checking with all the possibilities i tried with this http://localhost/magento/index.php/enable-cookies no sucess

    But i wonder it worked on Opera. Its no fun which i tought

  24. drumatic 01/25/2010, 7:16 pm:

    btw you can access your PC with http://www.you.com

  25. Felix Gomez 01/28/2010, 10:33 am:

    It works fine in Opera but has a problem in Firefox. I guess becaus firefox sucks!

  26. Best Content Management System 02/19/2010, 6:05 pm:

    I also experienced the same problem and was finally able to figure out how to install Magento locally onto my computer running Windows XP. Here is a step by step guide on how to install Magento with no errors! http://www.jvfconsulting.com/blog/117/How_To_Install_Magento_Locally_On_Windows_XP.html

  27. jignesh thummar 03/03/2010, 1:09 am:

    just give full read write permission to var folder and delete all session and cache file inside it thats it

  28. geofrey 03/09/2010, 3:23 am:

    why on earth does Opera work and others don’t? If it’s cookie related, surely it’s simply a setting that needs changing, but why do all other browsers have the opposite setting to Opera then?

    signed,

    Disgruntled user of the admin interface.

  29. Muhammad Akram Ali 03/18/2010, 7:56 am:

    First you need to download the opera and login into the admin panel (yes it work on opera!) then in the admin panel two or more notifications are blinking, first is the congif notification when you click on the config link then you go to the config link on this page you can find unsecure tab under this tab you just need to replace the basic url to the address e.g. “www.localhost.com/magento” then do the same with secure tab after that you just need to add one line in the windows host file
    “127.0.0.1 magento.localhost.com http://www.localhost.com
    then try on firefox or what the browser you like it works for me.

    Thanks,
    Akram.

    • Laddu 06/01/2010, 10:17 am:

      Cool, this one tottaly worked

  30. sam 05/28/2010, 4:21 am:

    I had done each and every solution exits but it was not working and lastly I tries in opera and guess it WORKS!!!!!!!!!!!
    thanks man…

    here only OPERA work..

  31. sid 11/14/2010, 8:00 am:

    Just do the following. Nothing needed more.

    app\\code\\core\\Mage\\Core\\Model\\Session\\Abstract\\varien.php

    comment this line and try

    $cookieParams = array(
    \’lifetime\’ => $cookie->getLifetime(),
    \’path\’ => $cookie->getPath(),
    \’domain\’ => $cookie->getConfigDomain(),
    \’secure\’ => $cookie->isSecure(),
    \’httponly\’ => $cookie->getHttponly()
    );

  32. Angel 11/17/2010, 1:07 pm:

    OOOOhhhhh tnks so much :D really work!!!!

  33. Chris 12/23/2010, 5:11 am:

    Try this trick, login in your admin panel using opera browser then go to
    System>Configuration>Web then change your base url into this format:

    http://127.0.0.1/magentorootdirectory/

    hit “save config”
    and you can now login using other browsers

    • mosidiot 09/06/2011, 3:43 am:

      This totally works! Nice. thanks!

  34. izmit evden eve nakliyat 03/02/2011, 8:31 am:

    very very, thanks,

  35. kocaeli evden eve nakliyat 08/01/2011, 4:46 pm:

    good sharing thanks

  36. Amay 09/08/2011, 9:47 am:

    Hi..

    I am trying to open magneto on my new system with win XP SP3, using Google chrome, but the page is not giving me access into it,
    where as it is working fine on my old system, What should I do to get it working on my new system, so that the page gets opened,

    I am not getting any errors, I want to do the store entries on my network to do the work faster,

    Please help..
    Amay.

  37. Lorie 11/29/2011, 8:03 am:

    Many thanks for finding the time to describe the terminlogy for the newbies!

  38. tuba 04/30/2012, 2:54 pm:

    I have a strange problem, I can create admin via admin, but new admin user’s id and password do not work. any idea? thanks!

  39. Shaun 10/23/2009, 4:04 am:

    Dude,

    UPDATE admin_user SET password=MD5(‘mypassword’) WHERE username=‘admin’;

    does the job!

Trackbacks/Pings

Leave a Reply

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

*




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">