Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Difference between and [localhost]

Posted on 2003-12-05
Medium Priority
Last Modified: 2012-08-13

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?

Question by:AArnie
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 49

Expert Comment

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

Both are same

LVL 11

Expert Comment

ID: 9886534
Your machine name should also map automatically to

Accepted Solution

Insolence earned 150 total points
ID: 9886946
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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

LVL 12

Expert Comment

ID: 9887577
localhost is an alias for

Expert Comment

ID: 9895454
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.

Expert Comment

ID: 10036271
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 ( resolves to the same IP address as my brothers ( 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.


Expert Comment

ID: 10134703
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.

Expert Comment

ID: 10307687
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...

Expert Comment

ID: 10548490
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

Expert Comment

ID: 11234642
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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question