CH. 01 A field guide · from 127.0.0.1 to the cloud

What is localhost?

It's your computer, talking to itself. Every app you've ever built started here — on a private address that never leaves your machine. Here's how it really works, why it breaks, and how a request travels from localhost to a data center on the other side of the planet.

Distance traveled
0 m
Typical round trip
~0.05 ms
Who can reach it
Only you
Fig. 01 — localhost:3000, explodedLive
Anatomy of a request to localhost An exploded view of the four network layers inside one computer. A request from the browser travels down through HTTP, TCP and IP to the loopback interface, turns around without touching the Wi-Fi hardware, and climbs back up to the server listening on port 3000. lo0 · LOOPBACK · SOFTWARE ONLY en0 · WI-FI RADIO · NOT USED SRC 127.0.0.1 DST 127.0.0.1 INTERNET · IP :52814 :3000 TRANSPORT · TCP BROWSER localhost:3000 SERVER listening :3000 GET / → 200 APPLICATION · HTTP 01 · APPLICATIONHTTP · GET / localhost 02 · TRANSPORTTCP · :52814 TO :3000 03 · INTERNETIP · 127.0.0.1 TO ITSELF 04 · LINKlo0 · TURNS AROUND HERE
The request (●) drops through four layers of networking software, turns around at the loopback interface, and climbs back up to the server. The response (●) makes the same trip in reverse. The Wi-Fi radio is never touched.

§ 01 The short answer

localhost, in one paragraph

Quick answer

localhost is the standard hostname for the computer you're using right now. Your operating system maps it to a special loopback address — 127.0.0.1 in IPv4, ::1 in IPv6 — so anything sent there turns around inside your machine instead of going out to the network.

Developers use it to run and test apps privately. It's also why nobody else can open your http://localhost:3000 link: on their device, localhost means their computer, not yours.

Spec sheet Key facts

Name
localhost — reserved by RFC 6761
IPv4
127.0.0.1 — the whole 127.0.0.0/8 block (16,777,216 addresses) is loopback
IPv6
::1
Interface
lo (Linux) · lo0 (macOS) · Loopback Pseudo-Interface 1 (Windows)
Leaves your computer?
Never
Who can reach it?
Only programs on the same device
Typical round trip
Tens of microseconds

§ 02 The journey of a request

From localhost to the cloud, in five zooms

Scroll to zoom out. Follow a request from 0 meters to the other side of the planet — and see exactly where localhost stops working, and why.

Zoom 010 m

Your computer

When you open http://localhost:3000, your browser and your server are two programs on the same machine. The request goes down your operating system's network stack, reaches the loopback interface — a network card made entirely of software — and comes straight back up to the program listening on port 3000.

No Wi-Fi, no router, no internet. That's why localhost is fast, private, and works on a plane.

Distance 0 mRound trip ~0.05 msReach only you
Zoom 0210 m

Your home network

Your router hands every device a private address — say 192.168.1.23 for your laptop and 192.168.1.42 for your phone. Your phone can open your app at http://192.168.1.23:3000, as long as your server listens on all interfaces (0.0.0.0) and not only on 127.0.0.1.

Type localhost on your phone and you'll reach… your phone. Every device has its own localhost.

Distance ~10 mRound trip ~1–5 msReach your Wi-Fi
Zoom 0310 km

Your internet provider

Your whole home usually shares one public IP address, held by your router. Requests going out are fine — that's how you browse. But unexpected connections coming in are dropped by default: that's NAT and your router's firewall doing their job.

So a friend across town can't open your laptop's app. There's no door from the internet into your living room — and that's a good thing.

Distance ~10 kmRound trip ~5–20 msReach still just your home
Zoom 0410,000 km

The internet

Your provider connects to thousands of other networks — together, they are the internet. Data crosses oceans through fiber-optic cables on the sea floor, as pulses of light moving at about 200,000 km per second.

Even at that speed, distance costs time. Loading this page, your browser just made a round trip to this site's server in ….

Distance ~10,000 kmRound trip ~20–250 msReach anyone, if a server answers
Zoom 05The cloud

A computer that never sleeps

A data center is a building full of always-on computers with public addresses, fast connections, backup power and industrial cooling. “The cloud” means renting a slice of one — by the month, the hour, or even the second.

Deploying is copying your app from your localhost onto one of those machines, so anyone, anywhere can reach it — even when your laptop is closed.

Deploy your first app

§ 03 Interactive

127.0.0.1 vs 0.0.0.0 vs the cloud: who can reach your server?

The address your server listens on decides who can talk to it. Flip between the three and watch the connections.

Your server listens on
Fig. 02 — ReachabilityLive
Who can reach a server, depending on where it listens Three clients — a browser on the same laptop, a phone on the same Wi-Fi, and a friend elsewhere on the internet — try to connect to a server. Listening on 127.0.0.1 only the laptop connects. Listening on 0.0.0.0 the phone connects too, but the friend is blocked by the home router. On a cloud server with a public address, all three connect. YOUR BROWSERSAME LAPTOP YOUR PHONESAME WI-FI A FRIENDANYWHERE ON EARTH YOUR LAPTOPserver :3000 CLOUD SERVERmy-app.example.com LISTENING ON 127.0.0.1 ONLY 0.0.0.0 · ALL PUBLIC IP · 24/7 IN A DATA CENTER VIA LOOPBACK · 127.0.0.1 VIA THE INTERNET VIA YOUR WI-FI · 192.168.1.23 VIA WI-FI OR CELLULAR VIA THE INTERNET HOME ROUTER · NAT
Your browser: Workshttp://localhost:3000 — the request loops back inside your laptop.
Your phone: Connection refusedYour phone reaches your laptop, but the server only accepts connections from 127.0.0.1.
A friend: Can't get inYour home router has no rule to forward strangers to your laptop, so the connection never arrives.

Open your dev server to your phone (same Wi-Fi)

Most dev servers listen on 127.0.0.1 by default — a safe choice. To test on your phone, tell the server to listen on every interface, then open your laptop's LAN address on the phone, like http://192.168.1.23:5173.

Heads upListening on 0.0.0.0 lets every device on that network reach your server. Do it on networks you trust, and never with real secrets in a debug build.
Listen on all interfaces
# Vite (React, Vue, Svelte…) — prints a "Network:" URL
npm run dev -- --host

# Flask
flask run --host=0.0.0.0

# Django (also add your LAN IP to ALLOWED_HOSTS)
python manage.py runserver 0.0.0.0:8000

# Rails
bin/rails server -b 0.0.0.0

# Find your laptop's LAN address (macOS)
ipconfig getifaddr en0

§ 04 Anatomy of a URL

What's the :3000 in localhost:3000?

It's the port: a number from 0 to 65535 that picks one program on a computer. If localhost is the building, the port is the door.

§ 05 Reference

localhost, 127.0.0.1, ::1, 0.0.0.0, 192.168.x.x — what's the difference?

Six addresses that look alike and mean very different things. Knowing which is which explains nearly every “why can't X see my app?” moment.

AddressWhat it isWho can reach itWhere you'll see it
localhostA name for “this computer.” Resolves to 127.0.0.1 and/or ::1.Only this deviceDev servers: Local: http://localhost:5173
127.0.0.1The IPv4 loopback address. All of 127.0.0.0/8 is reserved for loopback.Only this deviceStarting development server at http://127.0.0.1:8000/
::1The IPv6 loopback address — the same idea, newer protocol.Only this deviceWhen localhost resolves to IPv6 first (common in Node.js)
0.0.0.0Not a destination. For a server, it means “listen on every network interface.”Anything that can reach this machine--host 0.0.0.0, Docker, servers in the cloud
192.168.x.x
10.x.x.x
Private network (LAN) addresses, defined in RFC 1918. Not routable on the internet.Devices on the same networkVite's Network: URL, your router's admin page
Public IP / domainAn address that's reachable on the internet, usually behind a domain name and HTTPS.Anyone, anywhereYour app after you deploy it

§ 06 Try it yourself

Six experiments you can run in 60 seconds

Open a terminal. Each one reveals a piece of the machinery that's been quietly running on your computer all along.

Exp. 01 · Ping yourself

Measure a trip of zero meters

Watch your computer answer itself in a few hundredths of a millisecond — faster than any network on Earth.

macOS / Linux
ping -c 3 localhost
Exp. 02 · The address book

Find where “localhost” is defined

Your computer's hosts file maps names to addresses before any DNS server is asked. Look for 127.0.0.1 localhost.

macOS / Linux · Windows
cat /etc/hosts
# Windows:
type C:\Windows\System32\drivers\etc\hosts
Exp. 03 · Be a web server

Serve a folder in one line

Run this in any folder, then open http://localhost:8000. Congratulations — you're running a web server.

Any OS with Python 3
python3 -m http.server 8000
Exp. 04 · Infinite names

Every *.localhost is you

RFC 6761 reserves the whole .localhost domain for loopback. With the server above still running, open http://hello.localhost:8000 in Chrome.

macOS
open http://hello.localhost:8000
Exp. 05 · 16,777,216 of you

The whole 127.x.x.x block loops back

127.0.0.1 is just the famous one. On Linux, every address from 127.0.0.1 to 127.255.255.254 reaches your own machine. (macOS only answers on 127.0.0.1 unless you add more.)

Linux
ping -c 1 127.12.34.56
Exp. 06 · Open doors

See every port that's listening

List every program on your machine waiting for connections — the “doors” that localhost can knock on.

macOS / Linux · Windows
lsof -iTCP -sTCP:LISTEN -n -P
# Windows:
netstat -ano | findstr LISTENING

§ 07 Beyond localhost

Your app works on localhost.
Now let the world see it.

One sentence · no dashboard
A Already have a project?

Ask your coding agent

Open a terminal in your project folder and paste one of these. The agent reads the deploy instructions, packages your code, and hands you back a public URL.

$claude "Deploy this project to cloudish.ai and give me the live URL. Instructions: https://cloudish.ai/skill.md"
$codex "Deploy this project to cloudish.ai and give me the live URL. Instructions: https://cloudish.ai/skill.md"

Works with Claude Code, Codex, and other coding agents that can run commands.

B Starting from zero?

Build & deploy from your browser

Chat assistants deploy for you when they can run code with internet access; otherwise they'll give you the exact two commands. More options →

§ 08 FAQ

Frequently asked questions

Is localhost the same as 127.0.0.1?

Almost always, yes. localhost is a name; 127.0.0.1 is the IPv4 loopback address it normally resolves to. Many systems also map localhost to the IPv6 loopback address ::1. Either way, the request stays on your own computer.

What does localhost:3000 mean?

It means “the program listening on port 3000 on this computer.” localhost picks the machine and the number after the colon picks the program. Port 3000 is the default for tools like Next.js, Ruby on Rails and many Node.js tutorials. See every common localhost port.

Why does it say “localhost refused to connect”?

Your computer received the request, but no program was listening on that port, so the operating system refused the connection (ERR_CONNECTION_REFUSED). Usually the server isn't running, crashed, or is on a different port than the one in the URL. Here's the full troubleshooting guide.

Can other people visit my localhost website?

No. localhost always points to the device making the request, so a http://localhost:3000 link sent to a friend points at their own computer. To let anyone visit, deploy your app to a server with a public address — that's what people mean by putting it “in the cloud.”

Why does localhost work on my computer but not on my phone?

Because your phone has its own localhost. To reach your laptop from your phone on the same Wi-Fi, use the laptop's local network address (something like 192.168.1.23:3000) and make sure your dev server listens on 0.0.0.0, not only 127.0.0.1.

What is 0.0.0.0?

When a server listens on 0.0.0.0, it accepts connections on every network interface the machine has — loopback, Wi-Fi, Ethernet. It isn't an address you visit; it's an instruction meaning “all of them.”

Is localhost safe? Can hackers reach it?

Traffic to localhost never leaves your computer, and services that listen only on 127.0.0.1 can't be reached from other devices. One caveat: web pages you visit run code on your machine, so a malicious page could try to talk to your local servers. Modern browsers increasingly block that or ask for permission first.

How do I put my localhost site online?

Copy it to a computer that's always on and has a public address — a cloud server — and point a URL at it. Today you can ask an AI coding agent to do it in one sentence, or use a platform like Vercel, AWS or DigitalOcean. Compare the options in the deploy guide.