Why localhost has two addresses
Type localhost and you usually hit 127.0.0.1. Sometimes you hit ::1 instead, your app works in one terminal and dies in another, and nobody tells you why. Here's the actual reason.
Jodo
Jun 19, 2026 · 9 min read

Most explanations of loopback addresses start with a diagram you can't read and a wall of acronyms. This one starts with the question you actually asked, then builds the answer piece by piece until why localhost has two addresses feels obvious instead of intimidating.
How to read this
Every code block runs as-is. Copy it, change a number, watch what breaks. That's where the understanding comes from, not the prose.
Start with the problem
Before any of the machinery makes sense, you have to feel the problem it solves. So forget the official terminology for a second and look at what goes wrong without it.
// The naive version — works on your machine, fails in production
async function handle(req: Request) {
const data = await db.query(req.body.id)
return Response.json(data)
}Now the real version
Once the failure mode is clear, the fix stops looking like ceremony and starts looking like the only reasonable thing to do. Notice that nothing here is clever. It's just careful.
async function handle(req: Request) {
const id = parse(req) // validate at the edge
const data = await db
.query(id)
.catch(() => fallback(id)) // degrade, don't crash
return Response.json(data, { headers: cacheHeaders })
}- Validate at the boundary so bad input never reaches your core.
- Have a plan for the moment a dependency is slow or down.
- Measure the real path before you optimize the imagined one.
“You don't understand a system until you can predict how it fails.”
— every on-call engineer, eventually
Where to go next
You now have the mental model. The fastest way to lock it in is to break something on purpose: change a value, pull a cable, kill a process, and watch how the system reacts. The recovery is the lesson.
Developer Notes
Liked this? I send one like it every Friday.
Join 48K+ developers. No spam, unsubscribe in one click.
Subscribe
System DesignHow Stripe actually works
Your card gets charged in under a second, across half a dozen systems, in a way that survives a server dying mid-payment. I traced one $20 charge from click to settlement.
Jun 14, 2026 · 14 min read
AI & AgentsHow Cursor reads your whole codebase
It doesn't send your repo to a model. It chops it up, embeds it, and retrieves the three files that matter right before it answers. The trick is in what it leaves out.
May 27, 2026 · 12 min read
DevOpsHow Vercel deploys in seconds
Push to a branch and a URL is live before you switch tabs. Behind it: immutable builds, a global edge cache, and an atomic swap that can't half-deploy.
May 13, 2026 · 10 min read