A loopback address is a reserved IP address that points back to the same computer that sent the traffic. In IPv4 it is any address in 127.0.0.0/8, usually 127.0.0.1, and in IPv6 it is ::1. The hostname localhost resolves to these addresses. Packets sent to a loopback address never leave the device, so only programs on that machine can reach the service.
Key takeaways
- A loopback address always means this computer: 127.0.0.1 in IPv4 and ::1 in IPv6.
- Loopback traffic never leaves your device, so it is useful for local testing but invisible to other machines.
- The address a service binds to decides who can reach it: 127.0.0.1 means local only, while 0.0.0.0 means every interface.
Open a terminal, type ping 127.0.0.1, and you get a reply even with no Wi-Fi and no cable plugged in. That reply comes from your own computer, talking to itself through a loopback address.
What is a loopback address?
A loopback address is a reserved IP address that always refers to the computer sending the traffic. Any packet sent to it is delivered back to the same machine, without ever reaching a network cable, Wi-Fi radio or router.
The idea is simple: every host needs a way to test and use network services locally. The loopback interface is a virtual network interface, built in software, with no hardware behind it. When a program connects to a loopback address, the operating system hands the data to the program listening on that address and port.
Loopback traffic is handled inside the TCP/IP stack. As the loopback documentation explains, such packets are never passed to a network interface controller and must not appear outside the computing system. That rule is what makes loopback safe for local work by default.
What is the IPv4 loopback address?
The IPv4 loopback address most people use is 127.0.0.1, but the whole block 127.0.0.0/8 is reserved for loopback. That block runs from 127.0.0.0 to 127.255.255.255, which is more than 16 million addresses.
RFC 1122, the host requirements standard from October 1989, describes addresses of the form {127, any} as the "internal host loopback address" and states that they "MUST NOT appear outside a host". The IANA special-purpose address registry lists 127.0.0.0/8 as "Loopback", not globally reachable and not forwardable.
In practice, 127.0.0.1 is the conventional choice. Other addresses in the block also loop back on most systems, which lets you run several local services on the same port by giving each one a different loopback address, such as 127.0.0.2. Do not rely on that trick everywhere, because not every operating system treats the whole block the same way.
What is the IPv6 loopback address?
The IPv6 loopback address is ::1, short for 0:0:0:0:0:0:0:1. Unlike IPv4, which reserves a whole block, IPv6 defines exactly one loopback address.
RFC 4291 defines ::1 as the loopback address and says packets sent to it must never leave the node or be forwarded by a router. A packet addressed to ::1 that arrives on a real network interface must be dropped.
If you want to check how your network settings look in practice, our free DNS lookup tool shows how a name resolves for you.
When you use ::1 in a web address, wrap it in square brackets, for example http://[::1]:3000. The brackets keep the colons in the address from being confused with the colon before the port number. This rule comes from the URI standard, RFC 3986.
What is the difference between localhost and 127.0.0.1?
Localhost is a name, while 127.0.0.1 is an address. The name localhost normally resolves to 127.0.0.1 in IPv4 and to ::1 in IPv6, so the two usually lead to the same place.
The name is protected by a standard. RFC 6761 reserves localhost as a special-use domain name, and it also covers every name ending in .localhost, such as app.localhost. Name-resolution software should answer localhost queries with a loopback address without asking a DNS server.
The difference matters when a service listens on only one address family. If a server binds to 127.0.0.1 only and your system resolves localhost to ::1 first, the first connection attempt fails even though the server is running. Using the address directly, or binding the server to localhost, avoids that mismatch.
| Name or address | What it is | Defined in |
|---|---|---|
| localhost | Reserved hostname that resolves to loopback | RFC 6761, section 6.3 |
| 127.0.0.1 | Usual IPv4 loopback address | RFC 1122, section 3.2.1.3 |
| 127.0.0.0/8 | Whole IPv4 loopback block | RFC 1122; RFC 6890 registry |
| ::1 | Single IPv6 loopback address | RFC 4291, section 2.5.3 |
| 0.0.0.0 | Not loopback; means all interfaces when binding | RFC 1122, section 3.2.1.3 |
How does loopback work?
Your operating system creates a virtual loopback interface at startup, often called lo on Linux and macOS, or the Loopback Pseudo-Interface on Windows. It has no hardware, no MAC address of its own, and no cable.
When a program sends a packet to 127.0.0.1, the network stack recognizes the destination as loopback and queues the packet for local delivery. The packet goes through the same IP and transport layers as a normal packet, but it is delivered internally as though it had arrived from a wire.
That is why loopback is so useful for testing. You can run a web server, a database or an API on a laptop with no network at all, and a browser on the same laptop can still reach it. The service behaves like a real network service, minus the network.
You can see the interface yourself. On Linux, ip addr show lo lists it with inet 127.0.0.1/8 scope host lo. On Windows, ping localhost usually replies from ::1 in under a millisecond, because the packet never leaves the stack.
Loopback vs 0.0.0.0: which should you bind to?
The address a server binds to is its access control. Binding to 127.0.0.1 means the service accepts connections from the same machine only. Binding to 0.0.0.0 means it accepts connections on every interface, including your local network address.
For development, bind to 127.0.0.1 unless you have a reason to share the service with another device. That keeps a half-finished app, a test database or a debug server invisible to the rest of the network, even if your firewall rules are loose.
Bind to 0.0.0.0 only when you intend to share the service, for example when you want to test a site from your phone on the same Wi-Fi. Then check your firewall, use a strong password, and remember that a router port-forward can expose that service to the internet. Our guide to how to secure your Wi-Fi covers the router side of that risk.
| Bind address | Who can reach it | Typical use |
|---|---|---|
| 127.0.0.1 | This machine only (IPv4) | Private development, local databases |
| ::1 | This machine only (IPv6) | Same, on the IPv6 side |
| localhost | This machine only, either family | Default for many frameworks |
| 0.0.0.0 | Every interface on the machine | Sharing a service on the local network |
| 192.168.1.10 | Devices that can reach that LAN address | Serving one network on purpose |
What is a loopback address used for?
Loopback is used for local development, testing and internal services. Developers run web apps, APIs and databases on localhost, test them in a browser, and only later deploy them to a real server.
It is also used for diagnostics. Pinging 127.0.0.1 tests whether the TCP/IP stack itself works. If that ping fails, the problem is in the local stack, not in the cable or the router.
Some software uses loopback for internal communication. A local DNS resolver may listen on 127.0.0.53, a proxy may listen on 127.0.0.1, and containers often talk to services on the host through a loopback or gateway address. In Docker, localhost inside a container means the container, not your laptop, which is a common source of confusion.
Security tools use loopback too. A local firewall, VPN client or ad blocker can route traffic through a loopback service for filtering before it reaches the network. Because the traffic never leaves the machine at that stage, the filtering happens before any outside system sees it.
Is a loopback address safe?
Loopback is safe from remote attackers by design, because outside traffic cannot reach it. A router will not forward a packet addressed to 127.0.0.1, and the address is not globally reachable.
That does not make a localhost service automatically safe. Any program already running on your machine, including malware, can connect to a service on 127.0.0.1. If that service has no password, a weak password or a known flaw, local access is enough to exploit it.
There is also a proxy risk. Some browsers and tools are configured to skip the proxy for localhost, which is correct, but a misconfigured proxy can send local traffic to a remote server. Keep the loopback exception in place, keep local services updated, and do not bind a service to 0.0.0.0 just to make a quick test easier.
How do you fix localhost problems?
Most localhost problems come from three causes: the service is not running, it listens on a different address or port than you tried, or the name resolved to the other address family.
- Check the service is running. Look for its process, its log or its listening port before you blame the network.
- Check the port. A service on port 8000 will not answer on port 3000. The number after the colon picks the program, so it must match exactly.
- Try the address instead of the name. If
localhost:3000fails, try127.0.0.1:3000andhttp://[::1]:3000to see which family the service uses. - Check the hosts file. It should contain
127.0.0.1 localhostand::1 localhost. A changed hosts file can redirect localhost somewhere unexpected. - Check for a proxy. Some proxies intercept localhost traffic. Most systems bypass the proxy for loopback, so confirm that setting is still in place.
If ping to 127.0.0.1 works but the browser cannot connect, the stack is fine and the service is the problem. If ping fails too, the local network stack needs attention, and a restart of the network service or the machine is a reasonable next step.
Does loopback work the same in Docker?
No, and this catches many developers out. Inside a container, localhost means the container itself, not your laptop. A service running on your laptop at 127.0.0.1 is not reachable from inside the container through localhost.
To reach the host from a container, use the host gateway address that Docker provides, or run the container with host networking where that is supported. To reach a service in another container, use the container name or the Docker network address, not localhost.
The same idea applies to virtual machines. Each virtual machine has its own loopback interface, so 127.0.0.1 inside the guest is the guest, not the host. If you need the guest to reach a host service, bind that service to the host address the guest can reach, and protect it with a firewall rule.
The bottom line
A loopback address is your computer's way of talking to itself. IPv4 reserves 127.0.0.0/8, with 127.0.0.1 as the usual address, and IPv6 uses ::1. The name localhost resolves to both, and traffic to either one never leaves the machine.
Use loopback for local testing, bind services to 127.0.0.1 when they should stay private, and switch to 0.0.0.0 only when you mean to share them. If you want to see what your own machine looks like from the outside, run our free what-is-my-IP tool and compare that public address with the loopback addresses in this guide.
Frequently asked questions
What is a loopback address in simple terms?
It is an IP address that means this computer. When a program sends data to a loopback address, the operating system hands it straight back to another program on the same machine, instead of sending it out over a network cable or Wi-Fi.
Is 127.0.0.1 the same as localhost?
Almost. Localhost is a name, and 127.0.0.1 is an address. The name localhost normally resolves to 127.0.0.1 in IPv4 and to ::1 in IPv6. You can use either form in most cases, but they are not identical if a service listens on only one of them.
What is the IPv6 loopback address?
It is ::1, short for 0:0:0:0:0:0:0:1. Unlike IPv4, which reserves a whole block, IPv6 defines exactly one loopback address. In a web address you must write it in square brackets before the port number.
Can anyone else reach my loopback address?
No. Loopback traffic never leaves your device, and RFC 1122 says addresses in 127.0.0.0/8 must not appear outside a host. Another computer cannot connect to your 127.0.0.1, because on that computer the same address means itself.
What is the difference between 127.0.0.1 and 0.0.0.0?
127.0.0.1 means this machine only, so a service bound to it accepts local connections only. 0.0.0.0 means all interfaces, so a service bound to it accepts connections from the local network and, if the router allows it, from the internet too.
Why does ping 127.0.0.1 work with no internet?
Pinging a loopback address tests your own network stack, not your connection. The packet is handled inside the operating system, so it works even with no cable, no Wi-Fi and no router.
Is it safe to run a service on localhost?
Usually yes, because only programs on the same machine can reach it. It is not a complete defense on its own: malware already on the machine can still connect, so keep the service updated and do not assume localhost means private from other local users.
Why do developers use localhost ports like 3000 or 8000?
The port picks which program on the machine receives the connection. A development server listens on a port such as 3000, and your browser connects to localhost:3000 to reach it, without the service being visible on the network.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against RFC 1122, RFC 6761, RFC 4291 and RFC 6890, plus the IANA special-purpose address registry.
How we write and fact-check →