How to [always] redirect localhost to 127.0.0.1 when i type localhost?

Big_B

Big_B

@big-b-Qg3Tn6 Oct 26, 2024
Hi,
Is there any way to redirect localhost to always redirect to 127.0.0.1 when i type localhost ??

OS: Windows 8 32bit
Test Server: WAMP
Purpose: Testing Magento. and Admin login is not working on localhost. but working on 127.0.0.1.
but the problem is 127.0.0.1 keep redirecting to localhost! 👀

TIA. 😀
Big_B

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Nov 16, 2013

    localhost = 127.0.0.1 . I'm not sure where your browser is taking you. You may try editing hosts file : <a href="https://www.crazyengineers.com/threads/editing-c-windows-system32-drivers-etc-hosts-file-on-windows-vista.1749">Editing C:\Windows\System32\drivers\etc\hosts file on Windows Vista</a> and add entry-

    127.0.0.1 localhost
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Nov 16, 2013

    Big_B
    Hi,
    Is there any way to redirect localhost to always redirect to 127.0.0.1 when i type localhost ??

    OS: Windows 8 32bit
    Test Server: WAMP
    Purpose: Testing Magento. and Admin login is not working on localhost. but working on 127.0.0.1.
    but the problem is 127.0.0.1 keep redirecting to localhost! 👀

    TIA. 😀
    Big_B
    That's strange, which browser are you working on?
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    Kaustubh Katdare
    localhost = 127.0.0.1 . I'm not sure where your browser is taking you to. You may try editing hosts file : <a href="https://www.crazyengineers.com/threads/editing-c-windows-system32-drivers-etc-hosts-file-on-windows-vista.1749">Editing C:\Windows\System32\drivers\etc\hosts file on Windows Vista</a> and add entry-

    127.0.0.1 localhost
    I have the same code as you suggest in host file!

    127.0.0.1      localhost
    I face this problem only when i try to login to admin panel of Magento.
    otherwise everything works fine. 😀

    I have search on the Google on this problem and find a solution to update core file that solve the problem but #-Link-Snipped-# also said that,

    We do not recommend this solution for a production version of Magento, but for you local test environment this will work.
    is there any proper solution for this?
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    Manish Goyal
    That's strange, which browser are you working on?
    I am Using Chrome 30.0.1599.101
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Nov 16, 2013

    I don't remember exactly what I did for Magento last time when I had worked 2 years ago

    Just add one more entry to hosts file 127.0.0.1 xyz.com

    Then restart xampp or wamp and open xyz.com/magento, I don't which config file to edit, you can simply re-install magento
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Nov 16, 2013

    @#-Link-Snipped-# - You could quickly post the contents of your hosts file?
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    Kaustubh Katdare
    @#-Link-Snipped-# - You could quickly post the contents of your hosts file?
    Here is the content of host file:

    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97    rhino.acme.com          # source server
    #      38.25.63.10    x.acme.com              # x client host
    
    # localhost name resolution is handled within DNS itself.
    #    127.0.0.1      localhost
    #    ::1            localhost
    
    127.0.0.1      localhost
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Nov 16, 2013

    The hosts file looks okay. Since you're in Windows 8 environment, it will try to figure out the IPv6 addresses first before IPv4. Could you try totally removing

    # ::1 localhost

    from the file and then restarting your apache server? If that doesn't work, we'll have to make edits to the apache configuration (I think).
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Nov 16, 2013

    Update: If that doesn't work for you,

    edit httpd.conf file and change -

    Listen 80
    TO
    Listen 0.0.0.0:80
    Restart Apache and let us know if everything works fine for you. What this option does is ignore all the IPv6 range. Do restore it once you're done with your work on WAMP and you really want IPv6 powers 😀
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    Manish Goyal
    I don't remember exactly what I did for Magento last time when I had worked 2 years ago

    Just add one more entry to hosts file 127.0.0.1 xyz.com

    Then restart xampp or wamp and open xyz.com/magento, I don't which config file to edit, you can simply re-install magento
    I am running it on local so 127.0.0.1 xyz.com wont work, as it will be point to some actual domain xyz.com in this case.

    Re-installing will lost my all work. so finding the solution.
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Nov 16, 2013

    can you give me remote control of your system via team viewer?

    PM me your TV ID
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    Nothing working guys....
    Anyways re-install it Finally, all the things back to normal.
    Might be some problem with previous installation or else..

    Thank you guys for the quick support. 😀
    Tag: #-Link-Snipped-# , #-Link-Snipped-#

    --
    Big_B
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Nov 16, 2013

    @#-Link-Snipped-# - Did you try editing the httpd.config file to reflect the settings I mentioned above? That should work. Give it a try before you decide on starting from scratch.

    PS: If you have reinstalled everything by now, please let us know whether that solved the problem.
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    Kaustubh Katdare
    @#-Link-Snipped-# - Did you try editing the httpd.config file to reflect the settings I mentioned above? That should work. Give it a try before you decide on starting from scratch.

    PS: If you have reinstalled everything by now, please let us know whether that solved the problem.
    Yes first i have try editing httpd.config file as you said, but unfortunately that doesn't solve the problem.

    I Just Re-install the Magento... 😀

    Solution that work for me:
    On the installation they ask for the host name, if you type localhost there it wont work as happened with me, so this time instead of localhost i type 127.0.0.1 and that works. 😀
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Nov 16, 2013

    So the fix is that at the time of Magento, when the installer asks for the host name, choose 127.0.0.1 instead of localhost. If you set that option, Magento admin panel works on both #-Link-Snipped-# & #-Link-Snipped-# . Please confirm.
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Nov 16, 2013

    In a way, No that wont work on the localhost now.
    But it will redirect you (everytime) to #-Link-Snipped-# if you type #-Link-Snipped-# and where that will work as we have set that host 127.0.0.1 at installation. 😀
  • Romulo F. F.

    Romulo F. F.

    @romulo-f-f-4h7Ek2 Aug 4, 2014

    Hello #-Link-Snipped-#
    I was trying something similar to your solution as I'mrunning Magento with wamp 2.5, but wasn't having success and receiving an error on magento install with ip adress instead of localhost.
    If anyone have this problem, check the database user, mine was specified 'machine' localhost, and i changed to 'any machine' (%).

    After reinstalling, I searched the differences too, so i think that the problem can be solved withou reinstalling doing the following operations:
    1) change app\etc\local.xml <host> from localhost to your ip adress
    2) in the database, change table 'core_config_data', change column 'path' 'value' from paths: 'web/unsecure/base_url' and 'web/secure/base_url'.
  • Big_B

    Big_B

    @big-b-Qg3Tn6 Aug 10, 2014

    Cool! Nice Idea Romulo. Will try and post here if i find any issue. Thanks.👍