The IP address 127.0.0.1 is a special-purpose IPv4 address that is commonly referred to as the localhost or loopback address. All computers are assigned this address, but it doesn’t allow for communication with other devices like a real IP does.
In order to communicate with a router or other devices on a network, your computer might have the 192.168.1.101 private IP address assigned to it . However, it also attaches the special 127.0.0.1 address to itself, which other devices recognize as its “loopback” address.
The loopback address is only used by the computer you’re on for special circumstances, unlike a regular IP address that transfers files to and from other networked devices. For example, if you want to test a web server running on your own computer before deploying it, you can point it to 127.0.0.1 (aka “localhost”).
How 127.0.0.1 Works
Computers use the loopback address to communicate with itself. This is because every device is assigned an IP address, and that address is required for communication. The computer sees the loopback address as its own IP address, so it can communicate with itself just as it would with any other device on a network.
Loopback addresses are written in dotted decimal notation and always consist of four octets with values between 0 and 255. The first octet is always set to 127. For example, the loopback address for IPv4 would be written as 127.0.0.1 .
The IPv6 loopback address is written as ::1
The loopback address is also sometimes written as localhost or simply localhost. This is because the loopback address always points to the local machine, so using localhost is a more user-friendly way of referring to 127.0.0.1.
Each message a TCP/IP application software produces includes an IP address for its intended recipient.
TCP/IP recognizes 127.0.0.1 as a special IP address and double-checks each message before it sends to the physical network, automatically rerouting any messages with a destination of 127.0 back to where it came from, the receiving end of the TCP/IP stack.
To keep your network security tight, TCP/IP also checks for any incoming messages that might have loopback IP addresses. By doing this double check, it prevents anyone from disguising their traffic as coming from a safe source.
“localhost” is also a term used in computer networking that’s associated with the loopback address, 127.0.0.1. Operating systems have an entry in their HOSTS files that connects a name with the loopback address so applications can easily send messages using a name instead of having to remember a hard-coded number.
Just like IPv4 uses the loopback address 127.0.0.01, IPv6 uses ::1 (0000:0000:0000:0000:000 0000:0000 0001) as its loopback address instead- and it doesn’t set aside a range of addresses for this purpose either, making it unique from IPv4.
127.0.0.1 &. Other Special IP Addresses
The IPv4 address range from 127.0.0.0 up to 127.255.255.255 is set aside for use in loopback testing, but the vast majority of devices and applications will use the more conventionally accepted 127.0.0.1 as their loopback address instead
If you’re studying computer networking, you might confuse the 127.0.0.1 IP address with the 0.0.0.0 IP address. They both have special meanings in IPv4, but only 127.0.0.1 provides loopback functionality.