What Is 127.0.0.1? The Loopback Address Explained

The IP address that always refers to your own machine — and why every networked computer needs one

127.0.0.1: The Address That Points to Yourself

127.0.0.1 is the loopback address — an IP address that always refers to the local machine itself. When your computer sends data to 127.0.0.1, that data loops back to your own machine without ever leaving through a network interface or traveling over a physical network cable or wireless connection. This is why it's called "loopback."

You may have also seen it referred to as localhost. This is the hostname that resolves to 127.0.0.1 (or ::1 in IPv6). The mapping is defined in your operating system's hosts file (/etc/hosts on Linux/Mac, C:WindowsSystem32driversetchosts on Windows).

The entire 127.0.0.0/8 block is reserved for loopback — that's 16,777,216 addresses (127.0.0.1 through 127.255.255.254) that all loop back to the local machine. In practice, only 127.0.0.1 is ever used, but the whole range is reserved. This is defined in RFC 5735.

Key fact: traffic sent to the loopback address never touches your network card. It's handled entirely in the operating system's kernel network stack, making it extremely fast and useful for local inter-process communication.

The Loopback Interface: How It Works

Your operating system creates a virtual network interface called the loopback interface (named lo on Linux/Mac, or "Loopback Pseudo-Interface" on Windows). This interface has the address 127.0.0.1 and behaves like a real network interface for all practical purposes — processes can bind to it, send and receive packets, and operate as if they're communicating over a network.

When a process sends a packet to 127.0.0.1, the kernel intercepts it before it reaches the NIC (Network Interface Card) driver. The packet is immediately delivered back to the receiving process in the same kernel. This round-trip is measured in microseconds.

You can verify the loopback interface on your system:

Linux/Mac:

ip addr show lo
# or
ifconfig lo

Output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host

Windows: Run ipconfig /all and look for "Loopback Pseudo-Interface 1" showing address 127.0.0.1.

Practical Uses: Software Development and Testing

The loopback address is indispensable in software development. Whenever a developer runs a web server, database, or API locally, they connect to it via localhost or 127.0.0.1:

When a service binds to 0.0.0.0 (all interfaces), it's accessible from your network. When it binds to 127.0.0.1 only, it's accessible exclusively from that same machine — a simple but effective security boundary. Use our port checker to verify whether any local services are accidentally exposed to the internet.

IPv6 Loopback: ::1

IPv6 has its own loopback address: ::1 (full form: 0000:0000:0000:0000:0000:0000:0000:0001). It serves the same function as 127.0.0.1 in IPv4 — a locally significant address that loops traffic back to the same host.

In most modern applications and operating systems, both IPv4 and IPv6 loopback are available simultaneously. The hostname "localhost" can resolve to either 127.0.0.1 or ::1 depending on:

This can cause confusion when a service listens on 127.0.0.1:3000 (IPv4 only) but your browser connects to localhost which resolves to ::1 (IPv6). The solution is to either use 127.0.0.1 explicitly, have the service bind to both interfaces, or ensure the hosts file maps localhost to 127.0.0.1 preferentially.

Check whether your system prefers IPv4 or IPv6 using our IP checker — it shows both IPv4 and IPv6 addresses if your connection supports dual-stack.

Loopback in Network Diagnostics and Security

The loopback address serves critical roles in network troubleshooting and security:

Connectivity testing: Pinging 127.0.0.1 is the most basic network diagnostic — it tests whether the TCP/IP stack is functioning on your machine. If ping 127.0.0.1 fails, your network software has a serious problem regardless of what physical hardware is connected.

ping 127.0.0.1
# Should always succeed if TCP/IP is working

Blocking malware and ads: The hosts file can redirect unwanted domains to 127.0.0.1, preventing your browser from reaching them. Ad-blocking hosts files map thousands of ad-server domains to 127.0.0.1, so requests to those domains go nowhere. Tools like StevenBlack's hosts file use this technique.

# Example hosts file entry blocking an ad network
0.0.0.0 ads.example-adserver.com

Security research: Routing suspicious domains to 127.0.0.1 in the hosts file is a safe way to disable them. Running a packet analyzer on the loopback interface lets developers inspect inter-process communication without any traffic leaving the machine.

After any network configuration changes, use our DNS leak test to verify that DNS resolution is working as expected and not leaking through unexpected servers.

🛡️

Test Your Network Connectivity

Our free ping tool and DNS leak test help diagnose network issues in seconds.

Hide My IP Now
Special Offer

Frequently Asked Questions

Why is 127.0.0.1 called 'localhost'?

Localhost is the conventional hostname mapped to 127.0.0.1 in the operating system's hosts file (/etc/hosts on Linux/Mac). The name comes from 'local host' — the computer you're currently using. It's a shorthand so developers can type 'localhost:3000' instead of '127.0.0.1:3000'.

Is there a difference between 127.0.0.1 and 127.0.0.2?

Technically no — the entire 127.0.0.0/8 range loops back to the local machine. 127.0.0.2, 127.0.0.3, etc., all work as loopback addresses. However, only 127.0.0.1 is conventionally used. The additional addresses are occasionally used in advanced configurations that need multiple distinct loopback addresses (e.g., binding multiple services to different loopback IPs).

Can I ping 127.0.0.1 if I'm not connected to the internet?

Yes — pinging 127.0.0.1 works regardless of internet or network connectivity because the traffic never leaves your machine. It tests only the local TCP/IP stack. This makes it a useful first-step diagnostic: if ping 127.0.0.1 works but nothing else does, you know the network software is fine but there's a connectivity issue elsewhere.

What does it mean if a website is blocked by my hosts file at 127.0.0.1?

Your computer is redirecting requests for that domain to your own loopback interface instead of the real server. Since nothing is listening on the port being requested (unless you have a local server), you'll get a 'connection refused' or 'this site can't be reached' error. This technique is used by ad blockers, parental controls, and malware protection tools to block unwanted domains at the OS level.

Special Offer×