Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is localhost always = 127.0.0.1 ?

 
Oleksandr Karpus
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Is localhost always = 127.0.0.1 for Tomcat 4.0?
I did check it on 5 machines.
http://localhost:8080 always brings me "An error has occurred processing the request...
Unable to contact site SERVER
Press 'Refresh' on your browser to try again."
http://127.0.0.1:8080 is OK.
 
Rick Salsa
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Open up the Hosts file in C:\Windows in an editor. Add the following line at the bottom of the file:
127.0.0.1 localhost
That should do the trick. You can now use http://localhost:8080
/rick
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I enter this in the host file?
111.111.111.111 localhost
Then enter 111.111.111.111:8080 in browser?
Just a thought.
Thanks.
Bruce
 
Oleksandr Karpus
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rich salsa
I've always had a line "127.0.0.1 localhost" in my C:\winnt\system\drivers32\etc\hosts.
So It doesn't work.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17987
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You Don't want to remap localhost. This is a "magic" IP address and I don't know what would break but certainly wouldn't care to find out.
On my Linux system, the OS install created a line in the /etc/hosts file tagged with the comment that removing the localhost definition would "cause various programs that require network funcitonality to fail". The Windows equivalent to /etc/hosts is %WINDOWS%\LMHOSTS, but that file is not present by default, so I suspect that the definition for localhost is either hard-coded in the OS or hidden in some sneaky part of the Registry.
There are some OS's where localhost ISN'T defined by default - I believe I've read of Solaris being noted for that. However, it is ALWAYS defined for any Windows 9x/NT (or successor) networked machine.
If you really want to write something tied to your specific machine (as opposed to whatever machine you're running the software on) refer to it by its hostname - which is the machine ID it was given by the LAN administrator (visible in Network Neighborhood/Properties, aka "My Network Places/Properties").
If you enter "http://localhost" or "http://127.0.0.1" in your browser, it will look for a web server running at TCP/IP port 80 on your computer. If you want to access that server from another computer in your LAN and the machine ID is "FRED123", then say "http://FRED123".
Under Linux, IP 127.0.0.1 isn't attached to a physical network device - it uses a special device called the "loopback" device. Windows may be doing something similar for performance reasons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic