Skip to content
BENIBIX Learn

Localhost

Infrastructure🌐 NetworkingNetwork Addresses

Also known as 127.0.0.1, Loopback Address, Loopback Interface

The name a computer uses for itself. Traffic sent there never leaves the machine.

Think of it like

It is like writing a note to yourself. It never leaves your own desk.

Example

Emma runs her new site on her laptop. She opens localhost:3000 in her browser to see it, and nobody else can.

Why it matters

It lets you build and test in private. It is also why a database that listens only on localhost is safe from outside.

Definition

Localhost is the name a computer uses for itself. It points to the address 127.0.0.1, or ::1 in IPv6. Traffic sent there never leaves the machine. Developers use it to try a website on their own laptop before it goes live. A program that only listens on localhost cannot be reached from other machines.

Example code

console
$ ping -c 1 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.045 ms
Pinging localhost gets a reply at once. The packet never left the laptop.
The loop on the laptop is localhost. Its traffic turns round before it reaches the network.

Common mistake

Telling a friend to open localhost to see your work. On their machine, localhost means their own computer.

Key takeaways

  1. 1
    Means itself. Every machine has its own localhost.
  2. 2
    Never leaves. The traffic stays inside.
  3. 3
    Safe for testing. Others cannot reach it.

Learn it properly