IPv6 Loopback Address (::1)
Understand the IPv6 loopback address ::1, equivalent to IPv4's 127.0.0.1. Learn its expanded form, binary representation, and usage in dual-stack configurations.
Detailed Explanation
The IPv6 Loopback Address: ::1
::1 is the IPv6 loopback address, functionally equivalent to IPv4’s 127.0.0.1. Unlike IPv4, which reserves an entire /8 block (127.0.0.0/8) for loopback, IPv6 has a single loopback address.
Representations
| Format | Value |
|---|---|
| Compressed | ::1 |
| Expanded | 0000:0000:0000:0000:0000:0000:0000:0001 |
| Binary | 0000...0001 (127 zeros followed by a single 1) |
| Scope | Host (node-local) |
Expanded Binary
0000:0000:0000:0000:0000:0000:0000:0001
In binary (128 bits):
0000000000000000:0000000000000000:0000000000000000:0000000000000000:
0000000000000000:0000000000000000:0000000000000000:0000000000000001
Dual-Stack Behavior
On modern systems, localhost may resolve to either 127.0.0.1 (IPv4) or ::1 (IPv6), depending on the OS and DNS resolver configuration:
# /etc/hosts
127.0.0.1 localhost
::1 localhost
This can cause issues when applications bind to 127.0.0.1 but clients connect to ::1, or vice versa. To avoid problems, applications should either:
- Bind to
0.0.0.0and::(all interfaces) - Explicitly bind to both 127.0.0.1 and ::1
Key Differences from IPv4 Loopback
| Property | IPv4 | IPv6 |
|---|---|---|
| Address | 127.0.0.1 | ::1 |
| Range | 127.0.0.0/8 (16M addresses) | ::1/128 (single address) |
| DNS name | localhost | localhost |
Use Case
A developer debugging a Node.js application discovers that the server bound to 127.0.0.1 is unreachable via localhost because the system resolves localhost to ::1 (IPv6), prompting them to bind to both addresses.