Loopback Address: 127.0.0.0/8 Explained

Learn about the 127.0.0.0/8 loopback address range. Understand why 127.0.0.1 is localhost and how the entire /8 block is reserved for loopback use.

127.0.0.0/8IPv4

Detailed Explanation

Loopback Address: 127.0.0.0/8

The 127.0.0.0/8 address block is reserved for loopback — traffic that never leaves the local machine. The most famous address in this range is 127.0.0.1, universally known as localhost.

Key Details

  • Range: 127.0.0.0 to 127.255.255.255
  • Subnet Mask: 255.0.0.0 (/8)
  • Total Addresses: 16,777,216
  • Most Common: 127.0.0.1 (localhost)
  • Routable on Network: No — packets never leave the host

How Loopback Works

When a program sends a packet to any address in 127.0.0.0/8:

  1. The operating system's network stack intercepts the packet
  2. The packet is routed back to the sending machine
  3. It never reaches any physical network interface
  4. It never appears on the wire

This creates a virtual network interface (usually called lo on Linux or lo0 on macOS) that is always up and available.

Why an Entire /8?

While 127.0.0.1 is the address everyone uses, the entire /8 block (16.7 million addresses) is reserved. This may seem wasteful, but:

  • The reservation dates back to 1981 (RFC 790) when address space seemed unlimited
  • Some applications use other addresses in the range (e.g., 127.0.0.2 for testing multiple services)
  • Modern proposals to reclaim this space exist but face compatibility concerns

Common Uses

1. Local Development: Developers run web servers on 127.0.0.1:3000 to test applications without exposing them to the network.

2. Service Communication: Multiple services on the same machine communicate via different loopback addresses (127.0.0.1, 127.0.0.2, etc.).

3. Health Checks: Applications bind health-check endpoints to localhost so they are only accessible locally.

4. DNS Resolution: The system resolver at 127.0.0.53 (used by systemd-resolved on Linux).

Security

Binding a service to 127.0.0.1 instead of 0.0.0.0 ensures it only accepts connections from the local machine, providing a basic layer of access control.

IPv6 Equivalent

The IPv6 loopback address is ::1/128 — a single address rather than an entire block, reflecting IPv6's more efficient address allocation philosophy.

Use Case

A developer starts a local API server on 127.0.0.1:8080 during development, ensuring the service is only accessible from their own machine and not the network.

Try It — Subnet Calculator

Open full tool