# Localhost

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

**Field:** Infrastructure  
**Category:** Networking  
**Also known as:** 127.0.0.1, Loopback Address, Loopback Interface

## Think of it like

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

## 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

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

## 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.

## 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.

## Common mistake

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

## Three principles

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

## Related terms

- [Internet Protocol Address (IP Address)](https://learn.benibix.com/term/infrastructure/ip-address)
- [Network Port](https://learn.benibix.com/term/infrastructure/port)
- [ping](https://learn.benibix.com/term/infrastructure/ping)
- [Development Environment](https://learn.benibix.com/term/development/development-environment)

## Taught in

- [IP Addresses and Subnets](https://learn.benibix.com/learn/infrastructure-networking/ip-addresses-and-subnets): Computer Networking, 3/13

![Inside a home network marked 192.168.1.0/24, three devices hold private addresses that the router handed out. One laptop has a small loop marked 127.0.0.1 that turns back on itself. At the router, the private addresses are swapped for one public address, 203.0.113.7, which is the only address the internet sees.](https://learn.benibix.com/diagrams/inf2-addresses.svg)

---

Source: https://learn.benibix.com/term/infrastructure/localhost
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
