1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

localhost not working in firefox but works in IE

Discussion in 'Software Development' started by Dsyfa, Mar 27, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. Dsyfa

    Dsyfa Thread Starter

    Joined:
    May 23, 2007
    Messages:
    31
    Hi,

    I'm using XAMPP for development. I'm been facing a weird issue for the 2 days. I cant browse to http://localhost but I can browse to http://127.0.0.1 !! But I can browse to localhost using IE7. Whats going on?

    Thanks
     
  2. Rollin' Rog

    Rollin' Rog

    Joined:
    Dec 9, 2000
    Messages:
    45,855
    You'll have to be clearer about what you are trying to do -- which right now sounds like you are trying to see your own face without a mirror.

    "Localhost" is the computer you are using to browse with. You can "ping" it, but you can't "browse" to it; there is nothing to "display".

    If this is an "XAMPP" issue, of which I know nothing -- it might best be addressed in "Development".

    In fact, now that I see that that is what it is ... here you go >>
     
  3. Dsyfa

    Dsyfa Thread Starter

    Joined:
    May 23, 2007
    Messages:
    31
    Ok... XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. I use it to host my PHP sites in my machine. So, normally if I want to browse a website hosted in my machine, I would type in http://localhost/mysite into my browser. Browsing to http://localhost opens the default welcome page of XAMPP.

    Now, here's my problem. Firefox can open http://127.0.0.1/mysite but it can't open http://localhost/mysite; IE7 works both ways. Thats why I'm confused if this a XAMPP issue or browser issue??! :confused:
     
  4. tomdkat

    tomdkat Retired Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,148
  5. Dsyfa

    Dsyfa Thread Starter

    Joined:
    May 23, 2007
    Messages:
    31
    That's the interesting part... Nothing is displayed... No error, no 404 page, just a gray window!!
     
  6. tomdkat

    tomdkat Retired Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,148
    Hmmmm, that is strange. Can you try to view the page source when you get the gray window? Also, see if you can locate the Apache access log file. In there, we can see what HTTP status code is being sent to the browser and we can see if the browser is making it to Apache ok, etc.

    Peace...
     
  7. Dsyfa

    Dsyfa Thread Starter

    Joined:
    May 23, 2007
    Messages:
    31
    Ok, the source code I get when I point firefox to http://localhost is this:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body></body></html>
    
    I located the access log file. When I go to http://localhost, nothing gets appended to the log file. But, when I go to http://127.0.0.1, this is what I see:
    Code:
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET / HTTP/1.1" 302 -
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/ HTTP/1.1" 200 678
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/head.php HTTP/1.1" 200 1071
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/start.php HTTP/1.1" 200 1151
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/xampp.ico HTTP/1.1" 200 21630
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/xampp.css HTTP/1.1" 200 4663
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/logo-small.gif HTTP/1.1" 200 509
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/blank.gif HTTP/1.1" 200 43
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/navi.php HTTP/1.1" 200 4399
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/head-xampp.gif HTTP/1.1" 200 1404
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/head-for.gif HTTP/1.1" 200 791
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/head-windows.gif HTTP/1.1" 200 1478
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/xampp.js HTTP/1.1" 200 573
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/strichel.gif HTTP/1.1" 200 61
    127.0.0.1 - - [08/Apr/2008:12:33:11 +0600] "GET /xampp/img/apachefriends.gif HTTP/1.1" 200 979
    
    Whats going on here!! Pls help!!
     
  8. tomdkat

    tomdkat Retired Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,148
    Ok, please enter this command at a command prompt:

    ping localhost

    Then, post the output.

    Thanks! :)

    Peace...
     
  9. Dsyfa

    Dsyfa Thread Starter

    Joined:
    May 23, 2007
    Messages:
    31
    Code:
    C:\Users\Dsyfa>ping localhost
    
    Pinging Dsyfa-PC [::1] from ::1 with 32 bytes of data:
    
    Reply from ::1: time<1ms
    Reply from ::1: time<1ms
    Reply from ::1: time<1ms
    Reply from ::1: time<1ms
    
    Ping statistics for ::1:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
     
  10. tomdkat

    tomdkat Retired Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,148
    Ok, that appears to be A problem if not THE problem. Do you have IPv6 enabled or something? You will have to edit your hosts file to have localhost defined to 127.0.0.1. The hosts file will be on c:\windows\system32\drivers\etc, I believe on Windows XP. I think it will be in the same spot on Windows Vista. What I don't get is how IE7 resolves localhost if your ping resolves it as ::1:.

    The definition of localhost in your hosts file (which has NO file extension) will look like this:

    127.0.0.1 localhost

    There should be a syntax example in the hosts file already.

    Let us know what happens?

    Peace...
     
  11. Alan4573

    Alan4573

    Joined:
    Apr 11, 2008
    Messages:
    1
    Hi Guys,

    I have had this issue before - the problem is with the hosts file.

    c:\windows\system32\drivers\etc\hosts

    Open the file with notepad and you will see 2 entries for local host like this:

    127.0.0.1 localhost
    ::1 localhost

    Just delete the second one so you only have

    127.0.0.1 localhost

    You should now be good to go. :D
     
  12. tomdkat

    tomdkat Retired Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,148
    Great! Thanks for confirming! (y)

    Peace...
     
  13. Deimon

    Deimon

    Joined:
    Apr 14, 2008
    Messages:
    4
    I'm sorry to say this, but I don't have a line like that in my hosts file. I have the exact same problem as Dsyfa, except IE can't even browse localhost, as he can (I'm using IE8 Beta, but I'm sure I had the same problem while using IE7). And pinging localhost shows ::1: just as his does.

    Any more guesses of what the problem can be? Are there any more things that can redirect localhost to ::1: ? Like a software or something?
     
  14. tomdkat

    tomdkat Retired Trusted Advisor

    Joined:
    May 6, 2006
    Messages:
    7,148
    What does your hosts file contain? Can you post it here?

    Peace...
     
  15. Deimon

    Deimon

    Joined:
    Apr 14, 2008
    Messages:
    4
    Just the regular line and the comments.
    127.0.0.1 localhost
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/697518

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice