# localhost not working in firefox but works in IE



## Dsyfa

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


----------



## Rollin' Rog

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 >>


----------



## Dsyfa

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??!


----------



## tomdkat

What error does Firefox display when you point it at http://localhost/mysite ?

Peace...


----------



## Dsyfa

tomdkat said:


> What error does Firefox display when you point it at http://localhost/mysite ?
> 
> Peace...


That's the interesting part... Nothing is displayed... No error, no 404 page, just a gray window!!


----------



## tomdkat

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...


----------



## Dsyfa

tomdkat said:


> 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...


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!!


----------



## tomdkat

Ok, please enter this command at a command prompt:

ping localhost

Then, post the output.

Thanks! 

Peace...


----------



## Dsyfa

tomdkat said:


> Ok, please enter this command at a command prompt:
> 
> ping localhost
> 
> Then, post the output.
> 
> Thanks!
> 
> Peace...





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


----------



## tomdkat

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...


----------



## Alan4573

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.


----------



## tomdkat

Great! Thanks for confirming! :up:

Peace...


----------



## Deimon

Alan4573 said:


> 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.


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?


----------



## tomdkat

What does your hosts file contain? Can you post it here?

Peace...


----------



## Deimon

Just the regular line and the comments.
127.0.0.1 localhost


----------



## tomdkat

What results do you get when you issue the command "ping localhost" at a command prompt? Would you post the ping command and it's replies?

Thanks!

Peace...


----------



## Deimon

Code:


C:\Documents and Settings\Kenny>ping localhost

Pinging kab [::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


----------



## tomdkat

Ok, you're "suffering" from the same IPv6 issue the other person is suffering from. Try uninstalling IPv6 from your machine and see what happens.

Peace...


----------



## Dsyfa

Thanks a bunch everyone for your help and support!! :up:

Houston I'm ready for take-off!


----------



## tomdkat

Dsyfa said:


> Thanks a bunch everyone for your help and support!! :up:
> 
> Houston I'm ready for take-off!


Are you working now? What did you end up doing?

Peace...


----------



## Deimon

tomdkat said:


> Ok, you're "suffering" from the same IPv6 issue the other person is suffering from. Try uninstalling IPv6 from your machine and see what happens.
> 
> Peace...


Uninstalling? Isn't it enough with just disabling it?


----------



## tomdkat

Unless you're actually using IPv6 for something, I would uninstall it to keep things simple. 

Ultimately, it's your call. If you're not sure about which course of action is best, start a thread in the Networking forum about IPv6 'interfering' with your ability to access a locally running server.

Peace...


----------



## Dsyfa

I just deleted this line from my host file:



Code:


::1     localhost


----------



## tomdkat

Coolio! :up:

Peace...


----------

