Difference between localhost and


Difference between localhost and

Lots of people would think what the address
is when first seeing this address. In fact, is a loopback address which refers to the local machine. It is generally used for local testing. When typing ping
on local command console, it will send network packets to local IP/TCP layer to test whether IP/TCP works properly or not.

To those who are used to use localhost
, it is actually mapped to by default. There are hosts files in the system which store this mapping. Hence normally these two can be interchanged.

# localhost name resolution is handled within DNS itself. #       localhost # ::1             localhost       localhost

Is there any difference between localhost and What is it if there is?

Indeed, there is. Many people would think that it needs one less DNS resolution when using since localhost no need to be resolved. But there are differences. localhost is also called local, usually referred as the local machine
, while is usually considered as local address
. It’s very important to know that it will not go through network card when using localhost while it will when using, this means localhost will not be affected by network card configurations and firewall settings, all ports are open as well
. Generally speaking, localhost is a better option when configuring local testing environment. Sometimes some connection is working with localhost but is not working with is because of above reasons. Furthermore, when using localhost to access resource, it is accessed with the local user privileges, while it will use the network user privileges when using to access.

Below table summarizes the differences

localhost local IP(192.56.xxx.xxx)
Network Not connected Not connected Connected
Transmission No network card, not firewall restriction Network card, firewall restrictions Network card, firewall restrictions
Access Local access Local access(Network user privileges) Local or external access

Reference: https://my.oschina.net/fhd/blog/500778






Difference between localhost and