A loopback address is a reserved IP address that always refers to the local host itself, so any packet sent to it is delivered back to the same machine without ever leaving through a physical network interface. In Internet addressing, the loopback block for IPv4 is 127.0.0.0/8, with 127.0.0.1 as the conventional address, while IPv6 defines a single loopback address, ::1. The hostname localhost is the standard name that resolves to these addresses.
Loopback addressing lets software talk to other software on the same computer through the full TCP/IP stack, exactly as it would across the Internet. Developers, system administrators and network engineers rely on it for testing, local services and diagnostics, and the concept underpins how operating systems separate internal communication from external traffic.
How a loopback address keeps traffic inside the host
A loopback address works because the operating system routes it to a virtual loopback interface instead of a network card. On Linux this interface is usually called lo, on macOS lo0, and Windows implements an equivalent internal adapter. When an application sends a packet to 127.0.0.1, the IP layer recognizes the destination, hands the packet to the loopback driver, and the driver immediately injects it back into the receive path of the same stack.
Because no hardware is involved, loopback traffic is not subject to physical link speed, cabling faults or switch configuration. Throughput is limited mainly by CPU and memory bandwidth, so local transfers often reach many gigabits per second. The packets still pass through routing tables, firewall rules and socket buffers, which is why loopback is a realistic test of the software path while remaining isolated from the wire.
The following table summarizes the components that participate when a packet is sent to a loopback destination.
| Component | Role in loopback delivery | Typical name or setting |
|---|---|---|
| Loopback interface | Virtual device that returns packets to the stack | lo, lo0 |
| Routing table entry | Directs the loopback range to the virtual interface | 127.0.0.0/8 dev lo |
| Name resolution | Maps the name localhost to the addresses | hosts file entry |
| Firewall rules | May filter or allow local traffic | Accept on lo by default |
| Socket layer | Delivers data to the listening application | Bound port on 127.0.0.1 |
Reserved loopback ranges in IPv4 and IPv6
The loopback ranges are fixed by Internet standards, so every compliant host treats them identically. RFC 1122 requires that IPv4 addresses in 127.0.0.0/8 never appear on a network outside a host, and RFC 4291 defines ::1 as the IPv6 loopback address. The IANA special-purpose address registries list both blocks as not forwardable and not globally reachable.
A notable difference is scale. IPv4 dedicates an entire /8 block of about 16.7 million addresses to loopback, a decision from the early days of addressing that many engineers now regard as wasteful given IPv4 address exhaustion. IPv6 uses exactly one address, which reflects a more economical design. Linux answers on the whole 127.0.0.0/8 range by default, while some other systems configure only 127.0.0.1 unless further addresses are added.
| Property | IPv4 | IPv6 |
|---|---|---|
| Reserved range | 127.0.0.0/8 | ::1/128 |
| Conventional address | 127.0.0.1 | ::1 |
| Number of addresses | About 16.7 million | One |
| Defining specification | RFC 1122 | RFC 4291 |
| Forwardable by routers | No | No |
The localhost name has its own rules. RFC 6761 reserves localhost as a special-use domain name, and current guidance recommends that resolvers answer it locally with loopback addresses rather than forwarding queries to DNS servers. On a dual stack host, localhost may resolve to both ::1 and 127.0.0.1, and the order matters for which socket an application tries first.
Loopback address compared with related address types
A loopback address differs from other special addresses because it never identifies a network interface reachable by other hosts. Private IP addresses are routable inside an organization, and the unspecified address means no particular address at all. Confusing these categories is a frequent source of configuration errors, especially when deciding where a service should listen.
| Address type | Example | Reachable from | Main purpose |
|---|---|---|---|
| Loopback | 127.0.0.1, ::1 | Same host only | Local communication and testing |
| Unspecified | 0.0.0.0, :: | Not a destination | Bind to all interfaces |
| Private IP | 192.168.1.10 | Local network | Internal addressing behind NAT |
| Link-local | 169.254.x.x, fe80::/10 | Same network segment | Automatic addressing without a server |
| Public IP | 203.0.113.5 | Entire Internet | Global reachability |
The most practical distinction is between binding to 127.0.0.1 and binding to 0.0.0.0. A service bound to the loopback address accepts connections only from programs on the same machine, while a service bound to the unspecified address listens on every interface, including those facing the network. Choosing the wrong one can expose an administrative service to the outside world or, conversely, make a public service unreachable.
Practical uses of the loopback address
Loopback addressing is used wherever two programs on one host need to communicate through standard network APIs. The approach keeps code identical between local and remote deployments, because an application only changes the destination address. The table below lists common scenarios and the reason loopback suits each one.
| Scenario | How loopback is used | Benefit |
|---|---|---|
| Web development | Local server at localhost port 8080 | Testing without public exposure |
| Database access | Database listens on 127.0.0.1 only | Blocks remote connection attempts |
| Stack diagnostics | ping 127.0.0.1 or ping ::1 | Confirms TCP/IP stack is working |
| Reverse proxies | Application server behind a local proxy | Only the proxy faces the network |
| Router management | Loopback interface on a router | Stable address independent of links |
On routers and network devices, the term has an additional, related meaning. Engineers configure a loopback interface with a routable address, often a /32 in IPv4, to give the device a stable identity that remains reachable as long as any physical link is up. Routing protocols such as OSPF and BGP commonly use this address as a router ID or session endpoint. Unlike 127.0.0.1, such an address is deliberately advertised to other routers.
Limitations, security considerations and common mistakes
Loopback is not an absolute security boundary. Any process on the host, including malware or another user account, can connect to a service listening on 127.0.0.1. Local services therefore still need authentication and access control, particularly on shared servers and developer workstations.
Browsers add another dimension. Attacks such as DNS rebinding can trick a web page into sending requests to services on localhost, which is why modern browsers increasingly restrict public websites from reaching private and loopback addresses. Containers create a separate subtlety: inside a container, 127.0.0.1 refers to the container itself, not to the host machine running it.
- Assuming that localhost always means IPv4, which fails when it resolves to ::1 first and the service listens only on 127.0.0.1.
- Leaving a database bound to 0.0.0.0 when it was meant to accept local connections only.
- Expecting a containerized application to reach a host service through 127.0.0.1 without extra network configuration.
- Writing firewall rules that accidentally block the loopback interface, which breaks many local services at once.
In everyday language
A loopback address is like sending a letter to yourself using your own home address. The letter never goes to the post office; it simply appears back in your own mailbox. Computers use the address 127.0.0.1, or the name localhost, in the same way to talk to themselves.
This is useful because programs on one computer often need to exchange information as if they were on a network. With loopback, they can do that safely and quickly, without anyone outside being able to listen in on the network.
Seen in the real world
A web developer building an online booking system runs the application server, a PostgreSQL database and a caching service on a single laptop. The application connects to the database at 127.0.0.1 on port 5432 and to the cache on 127.0.0.1 port 6379, while the developer opens localhost port 3000 in a browser to test the interface.
When the team later deploys to a production server, the same configuration pattern keeps the database and cache bound to the loopback address, so only the application on that server can reach them. A reverse proxy listens on the public interface and forwards requests internally. A routine security scan from outside finds only the proxy ports open, confirming that the internal services are invisible to the Internet.