# Localhost

> The name a computer uses to talk to itself.

- Level: Basic
- Topics: Software, Networks
- URL: https://tidbit.legios.com.ar/localhost/
- In Spanish: [Localhost](https://tidbit.legios.com.ar/es/localhost/)

**Localhost** is the name every computer uses to mean "this same machine". When a program connects to `localhost`, the message never goes out to the network: the operating system turns it around and delivers it right back, through a virtual connection called the **loopback** interface. Its usual address is `127.0.0.1` in IPv4 and `::1` in IPv6.

Developers use it all the time. When you build a website, you run it on your own laptop and open something like `http://localhost:3000` in the browser. The `3000` is the port, which tells the computer which program should answer. Only you can see that site: nobody on the internet can reach your localhost, because for them, localhost is their own computer.

That is also a safety feature. A database or admin panel that only listens on localhost cannot be reached from outside. And it explains a classic confusion: "it works on my machine" sometimes means it works on localhost and nowhere else, because the real server is set up differently.

## An analogy

Writing yourself a note and leaving it on your own desk. It never goes through the post office, and nobody else can read it.

## Keep in mind

- Localhost always means "this computer".
- Its address is `127.0.0.1` (IPv4) or `::1` (IPv6).
- Traffic to localhost never leaves the machine.
- Developers try out sites at addresses like `localhost:3000` before putting them online.

## Go deeper

- [Localhost on Wikipedia](https://en.wikipedia.org/wiki/Localhost)
- [RFC 6761, which reserves the name localhost](https://datatracker.ietf.org/doc/html/rfc6761)

## Related terms

- [Operating system](https://tidbit.legios.com.ar/operating-system/): The base software that runs a device and lets every app share its hardware.
- [IPv6](https://tidbit.legios.com.ar/ipv6/): The newer internet addressing system, with practically unlimited addresses.
- [Website](https://tidbit.legios.com.ar/website/): A set of web pages under one address, stored on a server and opened in a browser.
- [Laptop](https://tidbit.legios.com.ar/laptop/): A whole computer folded into one portable case that runs on a battery.
- [Web browser](https://tidbit.legios.com.ar/web-browser/): The app that fetches web pages from the internet and draws them on your screen.
- [Port](https://tidbit.legios.com.ar/port/): The numbered door on a computer that says which program a connection is for.
- [Internet](https://tidbit.legios.com.ar/internet/): A worldwide network of networks that lets any connected device reach any other.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
