127.0.0.0/8: loopback
The whole of 127.0.0.0/8, 16,777,216 addresses, is reserved for loopback: traffic to any of them never leaves the machine. 127.0.0.1 is the conventional localhost address, but on Linux you can also reach the local machine at 127.0.0.2 or 127.1.2.3.
127.0.0.0/8 is 16,777,216 addresses: 127.0.0.0 to 127.255.255.255. 16,777,214 usable for hosts (the first is the network address, the last is broadcast).
- Network
127.0.0.0- First usable
127.0.0.1- Last usable
127.255.255.254- Broadcast
127.255.255.255- Addresses
16,777,216- Usable hosts
16,777,214- Netmask
255.0.0.0- Wildcard (ACL) mask
0.255.255.255- Historic class
A- Range type
Loopback · not routed on the internet
Special-purpose range
Loopback 127.0.0.0/8 RFC 1122
Addresses that loop back to the same machine. 127.0.0.1 is 'localhost', but the whole /8 is loopback.
Split it into subnets
4 subnets.
| Subnet | Usable range | Hosts | Broadcast |
|---|---|---|---|
127.0.0.0/10 | 127.0.0.1 – 127.63.255.254 | 4,194,302 | 127.63.255.255 |
127.64.0.0/10 | 127.64.0.1 – 127.127.255.254 | 4,194,302 | 127.127.255.255 |
127.128.0.0/10 | 127.128.0.1 – 127.191.255.254 | 4,194,302 | 127.191.255.255 |
127.192.0.0/10 | 127.192.0.1 – 127.255.255.254 | 4,194,302 | 127.255.255.255 |
Is this IP in the range?
Range to CIDR blocks
What to know
Services bound to 127.0.0.1 accept connections only from the same machine, which is the usual way to keep a database or admin panel off the network. Debian and Ubuntu map the machine's own hostname to 127.0.1.1 in /etc/hosts.
Linux routes the entire /8 to the loopback interface. macOS configures only 127.0.0.1 by default; other addresses need an alias (sudo ifconfig lo0 alias 127.0.0.2).
Gotchas
- Inside a Docker container, 127.0.0.1 is the container itself, not the host. A server listening on 127.0.0.1 inside a container is also unreachable through published ports; it must listen on 0.0.0.0.
localhostmay resolve to the IPv6 loopback::1first. A client connecting tolocalhostcan fail if the server listens only on 127.0.0.1, or the other way round.
Related explainers
- 169.254.0.0/16: link-local addresses169.254.0.0/16 is IPv4 link-local: self-assigned when DHCP fails, and home of 169.254.169.254, the cloud...
- What does /128 mean in IPv6?An IPv6 /128 is exactly one address, the IPv6 equivalent of an IPv4 /32. Used for loopbacks, host routes...
- What does /8 mean?A /8 fixes the first octet and leaves 24 bits for hosts: 16,777,216 addresses, netmask 255.0.0.0. The old...
- Private IPv4 address ranges (RFC 1918)The three private IPv4 ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Their sizes, exact...