Skip to main content

Localhost

Pronunciation
LOH-kul-hohst
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/localhost

In short

Localhost is the hostname for the computer you are using; it resolves to the loopback address 127.0.0.1 (::1 in IPv6), so its traffic stays on the machine.

What is localhost?

Traffic sent to localhost goes into the operating system's network stack and comes straight back out through a virtual loopback interface; it never reaches the network card or the internet. In IPv4 the whole 127.0.0.0/8 range is reserved for loopback, with 127.0.0.1 the standard address, and in IPv6 the loopback address is ::1.

Developers use it constantly. A dev server started with npm run dev is opened at http://localhost:3000, a local database listens on localhost:5432, and tools talk to each other through ports on the same machine. The port number tells the operating system which program should receive the traffic.

Browsers treat localhost as a secure context even over plain HTTP, so features that normally require HTTPS, such as service workers and the clipboard API, work during development. Many tools also distinguish 127.0.0.1 from 0.0.0.0: a server bound to 127.0.0.1 accepts only local connections, while one bound to 0.0.0.0 listens on every network interface.

A common misconception is that localhost inside a Docker container means your computer. Each container has its own network namespace, so localhost there is the container itself; to reach a service on the host, use the address Docker provides, such as host.docker.internal, or put both services on the same Docker network.

Key takeaways

  • Localhost is the name for your own machine, the loopback address.
  • It resolves to 127.0.0.1 in IPv4 and ::1 in IPv6.
  • Loopback traffic never leaves the computer.
  • Ports separate programs, as in localhost:3000 for a dev server.
  • Inside a container, localhost is the container, not the host.

Example

Binding a server to localhost or to every interface (Node.js)javascript
import http from "node:http";

const handler = (req, res) => res.end("Hello from this machine\n");

// Only reachable from this computer
http.createServer(handler).listen(3000, "127.0.0.1");

// Reachable from other devices on the network too (e.g. a phone on the same Wi-Fi)
http.createServer(handler).listen(3001, "0.0.0.0");

// curl http://localhost:3000   → works
// curl http://<your-LAN-IP>:3000 → refused; :3001 works

Readers ask

What is the difference between localhost and 127.0.0.1?

Localhost is a name and 127.0.0.1 is an address. The name usually resolves to 127.0.0.1, and on many systems also to ::1, the IPv6 loopback, which is why a server listening only on IPv4 can occasionally behave differently.

Can other people access my localhost?

No. Loopback traffic stays inside your machine. To let others reach a local server, it must listen on a network interface and be reachable through your network, or be exposed through a tunneling tool.

What does localhost:3000 mean?

Port 3000 on your own machine. Development servers commonly use ports such as 3000, 5173 or 8080, and the port tells the system which program should handle the request.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings