The 127.0.0.1 IP address is a unique IP address that is used by the Microsoft Windows operating system and some other software applications. It is also used by some websites, such as Google, Yahoo! and Amazon, and by some routers.

Reserved Addresses on the Internet

The Internet is made up of billions of devices. They identify and communicate with each other using IP addresses, which are conceptually similar to phone numbers. Internet Protocol Version 4 (IPv4), which have been in use for decades, allows for nearly 4.3 billion such addresses. The successor to IPv4, IPv6, has more than 10^38 addresses available — enough for every grain of sand on Earth, every star in the observable universe, and every atom in every person’s body to each have a unique IP address, with plenty left over.

Despite the huge number of IP addresses now available, it is convenient to reserve some addresses, or even ranges (usually called blocks) of addresses, for specific purposes to prevent programming conflicts. Reserving addresses for specific purposes makes it easy to establish general rules and behaviours for different IP addresses. Reserved IP addresses, like most internet standards, are established via documents called Requests for Comment, or RFCs.

As it turns out, it is often useful to have a computer talk to itself instead of another computer. For that, you need a special reserved IP address with some unique properties — 127.0.0.1.

RELATED: The Foundation of the Internet: TCP/IP Turns 40

What Is 127.0.0.1

127.0.0.1 is a host loopback address. Host loopback refers to the fact that no data packet addressed to 127.0.0.1 should ever leave the computer (host), sending it — instead of being sent to the local network or the internet, it simply gets “looped back” on itself, and the computer sending the packet becomes the recipient.

RFC 1122 explicitly says that “Internal host loopback address. Addresses of this form MUST NOT appear outside a host.” As a result, routers that pick up traffic directed to 127.0.0.1 are supposed to drop the packets immediately. This ensures that no traffic exclusively intended to be on the host computer ever makes it out onto the Internet.

Though it is the most common and most famous, 127.0.0.1 is just one address out of a large block, 127.0.0.0 – 127.255.255.255, that is reserved for loopback purposes in RFC 6890.

IPv6 has a loopback address, too. Fully written out it is 0000:0000:0000:0000:0000:0000:0000:0001, though that is usually truncated to ::1 for convenience.

How to Use 127.0.0.1

So why would you want packets to loop back to the same computer? There are a few common use cases.

The first is testing purposes — if you have a server or website you eventually intend to host over a LAN or on the Internet, you can run the server and client on the same computer to make sure all the fundamentals are working correctly first. For example, if you were hosting a dedicated Minecraft server on your local machine, you would connect to it by entering 127.0.0.1 as the IP address. The same would apply to almost any locally hosted server. Removing complications related to networking, like port configuration and latency issues for example, can make the troubleshooting process more efficient.

It is also possible you just want to run a service that is only accessible to you, on your local device. This is relatively common in the self-hosting community — it doesn’t make sense to unnecessarily expose a service to outside devices and threats.

The hosts file can be used to specify what IP address corresponds to a given domain name. Functionally, this lets you use 127.0.0.1 in your hosts file to block web traffic. For example, if you were to tell your computer to look for facebook.com at 127.0.0.1, it would fail to connect, effectively blocking it unless you had facebook.com’s actual IP memorized.

What Is localhost

In most cases, localhost is just shorthand that refers to 127.0.0.1 by default. It can be changed though — if you edit your hosts file, you can make localhost refer to any of the 127.X.X.X reserved addresses. You can also create other localhosts, like localhost2, that can refer to 127.0.0.2, for example.

As IPv6 is adopted more rapidly, it is likely that more and more devices will use ::1 for the default loopback address. However, 127.0.0.1 has been in use for decades, and will remain in use for the foreseeable future.