What Is Localhost and How Is It Different from

Even when every network device is disconnected, your computer can still communicate over a kind of network. Known as a “loopback,” a Unix machine can send and receive network communications from itself and to itself over a virtual network device. Your computer can send messages from itself to itself, permitting network-style communications without the need for a functioning network.

What is is the most commonly-used loopback IP address. It’s part of the reserved block of more than sixteen million IP addresses that are used specifically for loopback functionality. A loopback allows your computer to communicate with itself while using networking connection protocols.


In broad abstraction, a loopback is a virtual networking device that creates a network connection with only one endpoint, meaning that it begins and ends at the same device: your computer. In fact, the loopback device even shows up in ipconfig with the name lo, as seen above. The loopback addresses are primarily used for troubleshooting (it’s similar to looking in a mirror) or to access local resources over a network interface.

What is localhost?


“localhost” describes a communication port that connects to the originating server. It allows a network connection to “loop back” on itself, permitting you to emulate network connections when no such network is present or available. In practice, localhost is treated as synonymous with for usage and discussion. However, it’s important to remember that they are not strictly identical.

Before making a DNS request to translate the text string typed by the user into a navigable IP address, the operating system checks the HOSTS file for any aliases or redirect rules. On a system configured to standard defaults, “localhost” in a URI will resolve to under IPv4 or ::1 for IPv6. There are far more loopback addresses than just those two, however. The block of IP addresses reserved for loopback addresses stretches from to

In most all cases localhost will resolve to, thanks to a redirect rule in the HOSTS file, as mentioned above. But in some cases, localhost may be mapped to a different IP address. So, localhost could be pointed to any IP address in that block, and it would function identically.

Conclusion: What’s the Difference Between localhost and

On most machines localhost and are functionally identical. But localhost is a label for the IP address and not the address itself. Localhost could be pointed at different IP addresses. In fact, it could be pointed at any IP address, even one outside the reserved address block. The HOSTS file doesn’t care and won’t stop you. However, it will break significant functionality on your system and crash any app that relies on a localhost connection.

The 127 block of addresses was chosen for the loopback address block because it was the last block of Class A addresses, which run from the binary address value 00000001 to 01111111. In IPv6, the loopback address is the first address, 0:0:0:0:0:0:0:1, most frequently expressed in its truncated form as ::1.

If you’re coming from Windows to a Unix system, you might have noticed that loopback is practically synonymous with localhost. You can use your HOSTS file to make “loopback” redirect to, but that’s more of a text replacement than anything else.

Alexander Fox
Alexander Fox

Alexander Fox is a tech and science writer based in Philadelphia, PA with one cat, three Macs and more USB cables than he could ever use.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox