Link to home
Start Free TrialLog in
Avatar of AArnie
AArnie

asked on

Difference between 127.0.0.1 and [localhost]

Hi,

Can anyone explain to me what the difference between 127.0.0.1 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?

AArnie.
Avatar of sunray_2003
sunray_2003
Flag of United States of America image

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

127.0.0.1 localhost

Both are same

Sunray
Avatar of Zontar
Zontar

Your machine name should also map automatically to 127.0.0.1/localhost.
ASKER CERTIFIED SOLUTION
Avatar of Insolence
Insolence

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
localhost is an alias for 127.0.0.1
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:

http://127.0.0.1    - 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 (http://213.84.171.80) 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.

Vic
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/127.0.0.1, 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 127.0.0.1, 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 127.0.0.1 address.  cold fusion used the 127.0.0.1 for testing and it was the first time i ran into that local address...., but either way you should be able to use, 127.0.0.1 local host. ON my win2000 setup i added the address into the default web site properties. Its probably looking for your machine address, like 192.168.0.3 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 127.0.0.1 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.