• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 10218
  • Last Modified:

Difference between and [localhost]


Can anyone explain to me what the difference between and localhost is?

Some people I have spoken to say they are the same. Howerver, I have had the situation where when I try to view pages on hosted on an IIS 5.0 based machine (ie my XP Pro machine) one address may work and the other may not? ie, I can view them [the pages] using 127 but not using localhost - and vice versa.

Any suggestions?

1 Solution
Go to this place in windows xp   c:\windows\system32\drivers\etc\hosts
and check that file has something like localhost

Both are same

Your machine name should also map automatically to
I have had this problem and have researched why this occurs.  This used to happen to me a lot on linux, and happens sometimes on OS-X and Windows.  The difference is... is an IP address, and localhost is a hostname.

That may sound more simple of an answer than you want, but after my explanation below, you'll realize, this really is what the difference is.

First, is an IP address.  If you go to in your browser, your browser instantly knows where to go, it knows to try, which is the IP address of the loopback device on your computer.

Second, localhost is a hostname.  If you go to http://localhost in your bwoser, your browser doesn't instantly know where to start looking for "localhost".  It relies on your OSes dns-resolving subsystem to come back and tell your browser that localhost is located on  This tends to be a of your OSes dns-resolving subsystem's failure.  Basically, there's not too much you can do about this.  I have noticed this, and it pisses me off too.  I use linux as a desktop, and sometimes when I host sites on that same computer, I can use, and not localhost, or localhost and not for some of the sites.  Rediculous!

Another thing I have found, is this sometimes is a misconfiguration of the httpd.conf (apache) or configuration of IIS.  Playing with options sometimes fixes this.  =)

 - Insolence
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

localhost is an alias for
just another related info :

All the 127.*.*.* block is a loopback IP.
When hosting several sites on the same local sever you can specify on your web server which IP belongs to which site, thus preventing the need for virtual directory use.
Your browser also send the hostname you typed into the address bar in its HTTP request:
that means IIS will see if you typed:    - or -   http://localhost

You can tell IIS to serve different pages based on the hostname header in the HTTP request.
This is so that you can have multiple websites on your server with only one IP address.

An example is my own website. I share a server with my brother. So my domain (http://www.victorclaessen.nl) resolves to the same IP address as my brothers (http://www.felixclaessen.nl) and still if you visit those sites, you get served a different website. And if you go directly to the IP address that was resolved ( you get another webpage still...

So maybe its a IIS configuration thing. You can check it out by starting the IIS console from Adminstrative Tools. When you right click your website and view its properties. Look at the Web Site tab. There is a button labeled 'Advanced'. There you can view/edit your settings.

Hope this helpes.

To follow on from what Victor said, and to make an analogy of the setup to a telephone system..

In order to access a server, your machine needs to go to the IP address (the equivalent of a phone number).  The method by which that IP is mapped to a name, in the case of localhost/, is a local settings file (which can be changed, but it's unlikely); this is the equivalent of having numbers stored in your phone.

Now, if you ring a number that only has one person at the other end, you'll get them; but if you ring a number that is shared by 2 people, you'll need to specifically ask for whichever  person you need.

So if there is more than one site hosted on the server (i.e. more than one person at the phone number) and/or the server is configured to allow more than one site and so expects you to ask for a name (in order to decide which site to serve), you won't get through.
ok, when i was hosting cold fusion i ran into a little problem with my ports when i was in the testing phaze. Here was the deal. Local host and the ip of my machine seemed to work fine, but when i ran the, for some strange reason it was being blocked.  I have cable with a router, so i forwared port 80 back to myself then it allowed me to view my pages local with the address.  cold fusion used the for testing and it was the first time i ran into that local address...., but either way you should be able to use, local host. ON my win2000 setup i added the address into the default web site properties. Its probably looking for your machine address, like or whatever you use.  So, right click on default web site(or the name u use), properties, web site tab, then find the ip address its using, if you wanna see add that in for your local testing etc..., good luck  oh ps---you can probably go to the advanced tab and add multiple names etc...
how to mange a menu and a frame at the same page?
i have a menu below it immediately a frame ,when browsing the page the menu didnot appear above the frame
I had a similar problem in my development environment.  I was using webclasses in Visual Basic with Visual Studio - when I would try to run the code, it would try to access my website on localhost and it would fail if I was connected to a network, but would work if I disconnected or if I connected to a VPN.  It is a dns lookup problem and my ultimate solution turned out to be a simple setting in IE - in the LAN Settings, I needed to disable (clear the checkbox) under Automatic Configuration that said - Automatically detect settings.  Once I was on manual settings, everything worked fine.

Good luck.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now