Loopback
The network address a computer uses to talk to itself, where packets go out and come straight back without touching any hardware, the home of development servers and a recurring blind spot in security.
Loopback is a virtual network interface through which a computer sends traffic to itself. Packets addressed to it never reach a network card or a cable. The operating system's network stack hands them straight back as if they had arrived from outside.
In IPv4, the whole block of addresses starting with 127 is reserved for loopback, more than sixteen million addresses, of which almost everyone uses only 127.0.0.1. IPv6 reserved a single address, written ::1. The name localhost resolves to these addresses, and internet standards reserve it in the Domain Name System so it can never point anywhere else.
Because loopback uses the full network stack, programs written to talk over a network work unchanged when both ends are on one machine:
- Development. A web developer runs a server on localhost at some port and opens it in a browser; see Network Socket.
- Local services. Databases, caches, and helper daemons often listen only on loopback, so they can be reached by programs on the same machine but not from the network.
- Testing. A protocol can be tested end to end without any network at all.
The distinction between listening on 127.0.0.1 and on every interface, often written 0.0.0.0, is a common source of trouble. A service bound only to loopback is unreachable from other machines, which confuses people running it inside a container, where loopback belongs to the container's own network namespace. A service bound to every interface is exposed to the network, which is how many databases have ended up openly reachable on the internet; see Firewall.
Loopback is often treated as a trust boundary, and attackers have repeatedly found ways across it:
- Browsers. A web page can tell the browser to send requests to localhost, reaching local services that assumed only local programs could talk to them. Combined with tricks that make an attacker's domain resolve to 127.0.0.1, this has exposed development tools and device software; see Same-Origin Policy and Cross-Site Request Forgery.
- Servers. If an application fetches URLs on a user's behalf, an attacker can point it at its own loopback address to reach administrative interfaces; see Server-Side Request Forgery.
Browsers have added restrictions on public pages reaching local addresses, though rollout has been gradual because legitimate tools depend on that access.
The idea predates networking software. A loopback plug wires a port's transmit pins to its receive pins, so a device can test its own hardware by talking to itself; see Serial Port. A tired joke on shirts and doormats says there's no place like 127.0.0.1.
See also1
Linked from7
- Domain Name SystemSystems & Tooling
The distributed directory translating names to addresses, and the layer where propagation delays live.
- Inter-Process CommunicationSystems & Tooling
The channels separate processes use to exchange data and signals, from pipes and sockets to shared memory, a necessity because each process is walled off in its own memory and a frequent route for sandbox escapes.
- IPv6Networks & Distribution
IPv6 exists mainly to end address scarcity, with a large enough space that per-device NAT becomes optional.
- Linux NamespacesSystems & Tooling
The kernel feature that gives a process its own private view of a global resource — the foundation containers are built from.
- Network SocketNetworks & Distribution
The programming interface through which a program talks to the network, identified by an address and a port, and treated by the operating system as one more file descriptor.
- PortSystems & Tooling
The numeric endpoint a network service listens on, and a scarce shared resource on a developer machine.
- SubnetNetworks & Distribution
A block of IP addresses that share a common prefix, written in CIDR notation such as 192.168.1.0/24, which decides what a device can reach directly and what it must send through a router.