127.0.0.1 is the standard IPv4 loopback address, also known as localhost. Traffic sent to 127.0.0.1 never leaves your computer: your operating system routes it straight back to a service running on the same machine. Developers use it to test websites, apps and servers locally, and network tools use it to check that the local TCP/IP stack works.
Key takeaways
- 127.0.0.1 always points back to your own computer — traffic to it never reaches your router or the internet.
- Localhost is a hostname that usually resolves to 127.0.0.1 or ::1; 0.0.0.0 is different and means listen on every interface.
- A service bound only to 127.0.0.1 is reachable only from the same machine, which makes it a safe default for local development.
Type 127.0.0.1 into a browser and you are not visiting a website on the internet. You are talking to your own computer. That address, usually called localhost, is how developers test a site before it goes live and how network tools check that your computer can talk to itself.
What is 127.0.0.1?
127.0.0.1 is the standard IPv4 loopback address. It is the address your computer uses to refer to itself, so any connection to it stays on the same machine.
When a program connects to 127.0.0.1, your operating system routes the traffic through a virtual loopback interface. That interface exists only in software. No packet reaches your network card, your router or the internet.
The whole 127.0.0.0/8 block is reserved for loopback, which means any address from 127.0.0.1 to 127.255.255.254 routes back to the local machine. In practice, 127.0.0.1 is the standard address everyone uses, and the rest are rarely needed.
You will see it most often with a port number, for example http://127.0.0.1:8080. The address says which machine, and the port says which program on that machine should receive the connection.
What is the difference between localhost and 127.0.0.1?
Localhost is a hostname; 127.0.0.1 is an IP address. Localhost usually resolves to 127.0.0.1 for IPv4 and to ::1 for IPv6, while 127.0.0.1 always means IPv4 loopback.
On most systems the mapping lives in the hosts file: 127.0.0.1 localhost on Linux and macOS in /etc/hosts, and the equivalent file on Windows. Your system checks that file before it asks a DNS server.
The difference matters in one common case. If a service binds only to 127.0.0.1 and your browser tries ::1 first when you type localhost, the first attempt fails. Some clients fall back to IPv4; others stop there. Using 127.0.0.1 directly avoids that mismatch.
| Address or name | What it is | Who can connect |
|---|---|---|
| localhost | Hostname, usually 127.0.0.1 or ::1 | Only this computer |
| 127.0.0.1 | Standard IPv4 loopback address | Only this computer |
| ::1 | IPv6 loopback address | Only this computer |
| 0.0.0.0 | Unspecified address; listen on all IPv4 interfaces | Any device that can reach the machine |
| 192.168.1.10 | Example private LAN address | Devices on the same local network |
| Public IP | Address assigned by your ISP | Anyone on the internet, if the firewall allows it |
If you are unsure which address a service is using, check your own IP and listening ports first. Our free what-is-my-IP tool shows the public address your traffic appears from, which is a different address from 127.0.0.1.
How does loopback work?
Loopback traffic is handled inside your operating system's network stack. The packet is recognised as loopback, handed straight to the listening program, and never passed to a network interface controller.
That is why loopback works with Wi-Fi switched off and with no cable plugged in. It does not depend on your router, your ISP or your internet speed, and a ping to 127.0.0.1 should reply in well under a millisecond.
Because the traffic never leaves the machine, loopback is also a useful diagnostic. If ping 127.0.0.1 fails, the problem is in your local networking stack itself, not your router or your ISP.
What is localhost used for?
Developers use localhost to run and test a website, app or database on their own machine before deploying it. It is also used for network diagnostics and for testing domain settings safely.
Development and testing
A web server running on your laptop might listen on port 3000, 8000 or 8080. You open http://localhost:3000 in your browser and see the site exactly as it will look, but nobody else can reach it.
That isolation is the point. You can break things, restart the server and change code without affecting a live site or exposing an unfinished app to the internet.
Overriding a domain for testing
You can map a real domain to 127.0.0.1 in your hosts file so requests for that domain go to your local server instead. That lets you test a site using its production domain name before you deploy.
The same trick is used to block a domain: mapping it to 127.0.0.1 keeps requests on the local machine. For dependable blocking, though, use DNS filtering or a browser blocker rather than hosts entries alone.
Network diagnostics
Pinging 127.0.0.1 confirms that the TCP/IP stack on the local machine is working, independent of network hardware. If that ping fails, the local stack is the problem.
You can also list listening programs with commands such as ss -tlnp on Linux. A line showing 127.0.0.1:8080 means the service accepts connections only from the same machine.
127.0.0.1 vs 0.0.0.0: what is the difference?
Binding to 127.0.0.1 means local only. Binding to 0.0.0.0 means listen on every IPv4 interface, including your LAN interface, so other devices may be able to connect.
This is the most common localhost security mistake. A developer binds a database or admin panel to 0.0.0.0 for convenience, then forgets it is reachable from the whole office network or, worse, from the internet if the firewall allows it.
For local-only work, bind to localhost or 127.0.0.1. Only bind to 0.0.0.0 or your LAN address when you actually want other devices to connect, and then check the firewall. Our guide to how to secure your Wi-Fi covers the home-network side of that decision.
What do ports have to do with 127.0.0.1?
The address identifies the machine and the port identifies the program. That is why local URLs look like http://localhost:8080 instead of just http://localhost.
With no port, the browser fills in the default for the scheme: 80 for HTTP and 443 for HTTPS. A development server on port 8080 will not answer on port 80, so the browser reports that the connection was refused.
Common development ports are 3000, 5000, 8000 and 8080. On a default Linux system, ports below 1024 need extra permission to bind to, which is one reason development servers avoid them. If you run a local service, you can verify what it exposes with our free SSL checker once it is public, and keep local-only services on loopback while you test.
Is 127.0.0.1 safe?
Yes, as a destination it is safe, because the traffic never leaves your computer. The risk is not the address itself but the services you run on it.
A local service with a weak password, a default login or a known flaw can still be reached by malware already running on your machine. Some malware scans localhost for databases, admin panels and development tools.
Keep local services updated, use strong passwords even for local-only tools, and stop services you no longer need. If you want to check whether a domain resolves the way you expect, our free DNS lookup tool shows its public records.
How do you fix common localhost problems?
Most localhost errors come down to three causes: nothing is listening, the service bound to a different address than you used, or another program already holds the port.
Localhost refused to connect
Nothing is listening on the address and port you requested. Confirm the service is running, then check what it actually bound to with ss -tlnp on Linux or the equivalent on your system.
The service answers on 127.0.0.1 but not on localhost
Localhost can resolve to both ::1 and 127.0.0.1, and clients often try IPv6 first. If the service bound only to 127.0.0.1, that first attempt is refused. Either configure the service to listen on ::1 as well, or use 127.0.0.1 explicitly in the URL.
Address already in use
Another process already holds that port on the same address. Note that 127.0.0.1:8080 and 0.0.0.0:8080 conflict, because 0.0.0.0 covers the loopback address too. Find the process using the port and stop it, or pick a different port.
A new hosts entry has no effect
The hosts file is read for new connections, but browsers and long-running apps cache resolved names. Restart the client, and on systems running systemd-resolved flush the cache. Also check for duplicate entries mapping the same hostname to different addresses.
For a fuller history, the Wikipedia localhost article traces how the 127.0.0.0/8 block was reserved in 1981 and assigned for loopback in 1986, and the Linuxize localhost guide walks through the same commands on Linux.
The bottom line
127.0.0.1 is your computer talking to itself. It is the standard IPv4 loopback address, localhost is the hostname that usually points to it, and ::1 is the IPv6 equivalent. Traffic to any of them never leaves the machine.
Use 127.0.0.1 as your safe default for local development and testing, and treat 0.0.0.0 as a deliberate choice to open a service up. If you want to see the other side of the picture, check what your public IP address is and how it differs from the private, loopback world inside your own computer.
Frequently asked questions
What is 127.0.0.1 used for?
It is used to reach services running on your own computer, such as a local web server, database or development tool. Traffic to 127.0.0.1 stays on the machine, so it is a safe way to test software without exposing it to your network or the internet.
Is 127.0.0.1 the same as localhost?
Almost. Localhost is a hostname that usually resolves to 127.0.0.1 for IPv4 and to ::1 for IPv6. Using 127.0.0.1 skips hostname resolution and selects IPv4 directly, which avoids problems when a service listens on IPv4 only.
Can anyone else connect to my 127.0.0.1?
No. Traffic sent to a loopback address never leaves the machine, so other devices on your network cannot reach a service bound only to 127.0.0.1. To allow other devices in, the service must bind to your LAN address or to 0.0.0.0.
What is the difference between 127.0.0.1 and 0.0.0.0?
127.0.0.1 means this computer only. 0.0.0.0 is not a loopback address: when a server binds to it, it listens on every available IPv4 interface, including your LAN and loopback interfaces, so other devices may be able to reach it.
What is ::1?
The IPv6 loopback address is ::1. It does the same job as 127.0.0.1, but for IPv6 traffic. Localhost may resolve to ::1, 127.0.0.1, or both, depending on your system.
Why does localhost refuse to connect?
Nothing is listening on the address and port you requested. Check that the service is running, that you used the right port, and that it bound to the address you expect. A service listening on 127.0.0.1 will not answer on ::1, and vice versa.
Is 127.0.0.1 safe?
Yes, as a destination it is safe because the traffic never leaves your computer. The risk comes from what you run on it: a local service with a weak password or a known flaw can still be reached by malware already on your machine, so keep local services updated.
Why do developers use ports like 3000 or 8080 with localhost?
Ports below 1024 are privileged on Linux and need extra permission to bind to, so development servers default to higher ports such as 3000, 5000, 8000 and 8080. The port identifies which local program receives the connection.
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 Linuxize's localhost guide, the Wikipedia localhost article and RFC references for loopback and special-use domain names.
How we write and fact-check →