Friday, September 7, 2012

difference between localhost and local ip

What is the difference between the localhost and the real ip address? If I access an application by using http://localhost:8080/index.html and http://192.123.456.001:8080/index.html (for example, 192.123.456.001 is the real ip address of the host computer), what is the difference?
When you access localhost, your /etc/hosts file will tell your computer not to look any further and redirects you to your own computer. When you access the local IP adress, your computer will ask the router to fetch the data, and your router will then point back to your computer.
Is always a different ip address to the machines ip address? is not just a different ip address to the machine ip address, it's a different interface as well. should not be seen on the local network. It's a special internal IP address for the loopback adapter.
x.x.x.x will be your ethernet card.
by the way 'localhost' is simply an entry in your hosts file that points to
If you bind a socket to then only clients running locally will be able to access it and only with or http://localhost:8200 (or a dns or hosts file entry that points to
A socket bound to x.x.x.x:8200 will only be available through http://x.x.x.x:8200 or a dns or hosts file entry that points to that.
Binding a socket to does not automatically make it available on the ethernet interface as well.
Thats why you can't connect to x.x.x.x:8200
You can bind port 8200 to all available interfaces ( then it should work.
Why is there a difference between ping “localhost” and ping “local IP address”?
You are not pinging the same interface, without any physical interfaces you still have a "local host".
Your localhost is used to refer to your computer from its "internal" IP, not from any "external" IPs of your computer. So, the ping packets don't pass through any physical network interface; only through a virtual loop back interface which directly sends the packets from port to port without any physical hops.
You might still wonder why localhost is resolving to ::1, while traditionally we would expect it to resolve to the IPv4 address Note that .localhost is traditionally a TLD (see RFC 2606) which points back to the loop back IP address (for IPv4, see RFC 3330, especially