← Back to Blog
localhostip-addressnetworkingdevelopers

What Is Localhost? 127.0.0.1 and ::1 Explained With Tests

Published Last checked 8 min readOutline Technologies
A loop of light leaving a small chip and returning to the same chip

The short answer

Localhost is the name your computer uses for itself. It points to a loopback address, 127.0.0.1 on IPv4 or ::1 on IPv6, and traffic sent there never leaves the machine. The whole 127.0.0.0/8 block, 16,777,216 addresses, is reserved for this, and RFC 1122 says those addresses must not appear outside a host.

16,777,216

addresses in 127.0.0.0/8, all of them loopback

::1

what localhost resolved to first in our Windows 10 and Node 24 tests

0

devices on your network or the internet that can reach your localhost

You type localhost into a browser, a page appears, and nothing about it touches the internet. That is the whole point of localhost: a way for your computer to talk to itself using the same tools it uses to talk to everyone else.

Localhost at a glance

ItemValueWhere it is defined
NamelocalhostRFC 6761, section 6.3
IPv4 loopback block127.0.0.0/8 (127.0.0.0 to 127.255.255.255)RFC 6890 and RFC 1122
Usual IPv4 address127.0.0.1
IPv6 loopback address::1 (written in full as 0:0:0:0:0:0:0:1)RFC 4291
Addresses in the IPv4 block16,777,216Counted from the /8 prefix
Reachable from your network or the internetNoRFC 1122: "MUST NOT appear outside a host"
Treated as secure by browsersYes, even over httpMDN secure contexts

What is localhost, exactly?

Two things share the word.

Localhost the name. RFC 6761 reserves the name localhost and says name lookups for it "will always resolve to the respective IP loopback address". Your computer is expected to answer that lookup itself rather than send it to a DNS server on the internet.

Loopback the address. 127.0.0.1 and ::1 are addresses that belong to a virtual network card inside your computer. Anything sent to them is handed straight back to the operating system. RFC 1122 describes the 127 block as the "internal host loopback address" and says such addresses "MUST NOT appear outside a host".

So when a browser opens http://localhost:3000, it looks up the name, gets a loopback address, and connects to port 3000 on the same machine.

Is localhost the same as 127.0.0.1?

Close, but not quite, and the difference is behind a lot of "it works on my machine" puzzles. We tested it on a Windows 10 laptop (build 19045) with Node 24.13.0 on 21 November 2026.

TestResult
Resolve-DnsName localhost (Windows PowerShell)::1 (IPv6) and 127.0.0.1 (IPv4)
ping localhostReplied from ::1, so IPv6 came first
ping 127.45.6.7Replied. The whole 127 block answers on this machine
Node dns.lookup("localhost", { all: true })::1 first, then 127.0.0.1
Server listening only on 127.0.0.1, opened as http://127.0.0.1:portWorked
Same server opened as http://localhost:port from Node 24Worked, because Node tried the second address after the first failed
Same server opened as http://[::1]:portConnection refused

The last three rows are the useful part. A server that listens only on 127.0.0.1 is not listening on ::1. Whether localhost works then depends on the client. Node 24 tried the next address when the first one failed, so the request still worked. A client that tries only the first answer gets "connection refused" instead.

If one tool connects and another says "connection refused" to the same localhost address, this is the first thing to check.

How do I make a server answer on both 127.0.0.1 and ::1?

Tell it which address to listen on, or leave the choice to the platform. Three common cases:

SettingWhat it listens onReachable from other devices?
127.0.0.1IPv4 loopback onlyNo
::1IPv6 loopback onlyNo
localhostWhatever the name resolves to, often bothNo
No address at all (Node)All addresses, IPv6 and usually IPv4 tooYes, if your firewall allows it
0.0.0.0Every IPv4 address on the computerYes, if your firewall allows it

Node's net documentation explains the "no address" row: if the host is omitted, the server accepts connections "on the unspecified IPv6 address (::) when IPv6 is available", and on most operating systems that also covers IPv4. That is convenient on a laptop at home and a reason to set an explicit loopback address on shared Wi-Fi.

For a server only you should reach, localhost is the friendliest choice, because it follows whatever your system resolves. If a tool still refuses, use 127.0.0.1 on both sides, server and client, and the problem disappears.

What do localhost ports mean?

The number after the colon is the port: which program on your computer should receive the request. Development tools pick a default so you know where to look. These are the defaults each project's own documentation gives:

Next.js and Rails share port 3000, so running both at once makes the second one fail or move. Vite's documentation says that if its port is already in use it "will automatically try the next available port", which is why you sometimes find a Vite app on 5174.

Can anyone else reach my localhost?

No. That is a feature, and it is why a development server is safe to run on a laptop in a café.

The flip side catches people out: your phone on the same Wi-Fi cannot open localhost on your laptop either, because on the phone, localhost means the phone. To test a site from another device you need the laptop's local network address (something like 192.168.1.20), and the server has to listen on it. Django's docs say its server "runs on port 8000 on the IP address 127.0.0.1" by default and that you can pass in another IP address and port, which is how you open it to your network on purpose.

Listening on 0.0.0.0 means every address the computer has, including the network one. Only do that on a network you trust.

What does localhost mean inside Docker?

Containers have their own network, so localhost inside a container means the container, not your computer. Docker's documentation says, for example, that a container started with --dns=127.0.0.1 "refers to the container's own loopback address".

That causes a common surprise. A database running on your laptop at localhost:5432 is invisible to an app inside a container that tries localhost:5432, because the app is looking at its own loopback. Docker Desktop provides a special name for this case: its networking guide says host.docker.internal "Resolves to the internal IP address of your host". Point the app at host.docker.internal:5432 instead.

The same idea applies the other way round. A server inside a container that listens only on its own 127.0.0.1 cannot be reached through a published port, so containerised servers are usually told to listen on all addresses inside the container, and the port mapping decides what your computer exposes.

Where the program runsWhat localhost means there
Your computerYour computer
A Docker containerThat container only
A virtual machineThat virtual machine only
Your phoneYour phone
A remote server you connect toThat server

How is localhost different from my IP address?

AddressWho can reach itExample
LoopbackOnly your own computer127.0.0.1, ::1
Local (private) addressDevices on the same home or office network192.168.1.20
Public addressThe whole internet, through your routerThe one shown on our home page

Your public address is the one websites see. Localhost never appears to them at all. If you want to see which addresses your machine really exposes, our port scanner checks common ports on your public address from the outside.

What to do when localhost does not work

  1. Make sure the server is running. Read its startup message. It prints the exact address and port it is listening on.
  2. Use exactly that address. If it says 127.0.0.1:8000, open http://127.0.0.1:8000 instead of localhost, which removes the IPv6 question entirely.
  3. Check whether something else holds the port. On Windows, run netstat -ano | findstr :3000 and match the last number, the process ID, in Task Manager. On macOS and Linux, run lsof -i :3000. The netstat reference lists the switches.
  4. Make the server listen on both address families, or set it to localhost instead of 127.0.0.1, if a client insists on IPv6.
  5. Check the hosts file if localhost resolves strangely. On Windows it is C:\Windows\System32\drivers\etc\hosts. On our test machine the localhost lines in that file are commented out and the comment says "localhost name resolution is handled within DNS itself".
  6. Turn off a VPN or proxy if the browser sends localhost traffic away. Some proxy settings need a bypass for localhost.

The one line version

Localhost is your computer's name for itself, and it points to 127.0.0.1 or ::1. Nothing sent there leaves the machine, which makes it the safe place to run things before anyone else sees them. When localhost and 127.0.0.1 behave differently, the reason is almost always IPv6: localhost may try ::1 first, and your server may only be listening on 127.0.0.1. To see the addresses the rest of the world uses for you, check what your IP address reveals or compare IPv4 and IPv6.

Frequently asked questions

What is localhost?

Localhost is the hostname for your own computer. It resolves to a loopback address, 127.0.0.1 on IPv4 or ::1 on IPv6, so anything you send there goes straight back to the same machine without touching the network.

Is localhost the same as 127.0.0.1?

Usually, but not always. Localhost is a name and 127.0.0.1 is one address it can point to. On our Windows 10 test machine, localhost resolved to ::1 first and 127.0.0.1 second, so a program that only listens on 127.0.0.1 can behave differently depending on which one a client tries.

Can other people access my localhost?

No. Loopback traffic never leaves your computer, and RFC 1122 says loopback addresses must not appear outside a host. To let another device on your network reach a development server, the server has to listen on your local network address, which most tools only do when you ask.

What does localhost:3000 mean?

It means port 3000 on your own computer. Next.js and Ruby on Rails both tell you to open http://localhost:3000 in their getting started guides, so a page there is usually a development server you started yourself.

Why does localhost refuse to connect?

Nothing is listening on that port, the server stopped, or it is listening on the other address family. Check that the server is running, read the address it prints when it starts, and try http://127.0.0.1 with the same port.

Do other 127 addresses work?

On our Windows 10 test machine, 127.45.6.7 answered a ping just like 127.0.0.1, because the whole 127.0.0.0/8 block is loopback. On other systems, check before relying on any 127 address other than 127.0.0.1.

Is localhost secure in a browser?

Browsers treat it as a secure context even over plain http. MDN lists http://localhost as secure, which is why features that normally need https, such as service workers, work on a local development server.

Cite this article

“Localhost is the hostname a computer uses for itself, resolving to the loopback address 127.0.0.1 (IPv4) or ::1 (IPv6). The 127.0.0.0/8 block holds 16,777,216 loopback addresses, and RFC 1122 states that such addresses must not appear outside a host.”

Outline Technologies, “What Is Localhost? 127.0.0.1 and ::1 Explained With Tests”, whatismyip.technology, November 22, 2026. https://whatismyip.technology/blog/what-is-localhost

Free Tools

Test your network now

Everything discussed in this post can be tested for free. No account required.

Published by Outline Technologies · whatismyip.technology