What is localhost? Loopback, 127.0.0.1 and ::1
localhost normally means “this machine”: the one the request is made from. Its familiar addresses are IPv4 127.0.0.1 and IPv6 ::1. Traffic sent to them is handled inside the machine’s own network stack and never travels through the home router to the Internet. A localhost test therefore answers one narrow question: does the service work locally?
Which addresses count as loopback
IPv4 reserves the whole 127.0.0.0/8 block for loopback, although examples almost always use 127.0.0.1. IPv6 has a single special address, ::1/128. Their roles are described in RFC 1122 and RFC 4291.
The name localhost usually resolves to these addresses through local system configuration, without a query to an outside DNS server. An application may try IPv4 or IPv6 first. If a service listens on only one of them, the name can work in one program and fail in another, and that does not necessarily mean that the whole network is broken. Trying the numeric address directly shows which family the service answers on.
Why localhost on your phone does not open the site on your computer
A developer starts an application listening at 127.0.0.1:8000 and opens http://localhost:8000 on the same computer. This is a useful test that does not expose the application to other devices. If a phone on the same Wi-Fi opens localhost:8000, the phone tries to connect to itself, not to the developer’s computer.
To reach the application from the phone, three things must hold: the service must listen on a suitable network interface, the computer’s firewall must permit the connection, and the phone must use the computer’s LAN address. Do not publish a development server to the wider Internet without appropriate protection.
What 127.0.0.1 and 0.0.0.0 mean as listening addresses
A service bound only to 127.0.0.1 or ::1 is not directly reachable from another device. Binding to 0.0.0.0 in IPv4 generally means listening on all applicable IPv4 interfaces. Similar IPv6 behaviour depends on the application and system settings.
Listening on every interface still does not guarantee outside access. Firewalls, containers, NAT and provider rules may block the path. The checks also run in one direction only: an Internet-facing port check tests what is reachable from outside, so it cannot confirm that a loopback-only service is functioning locally. Test locally first, then test each network boundary separately.
“It worked on my laptop”: localhost in containers and on servers
Inside a container or on a remote server, localhost means that container or that server, not your laptop. A database connection string pointing at localhost can therefore work during local development and fail after deployment, when the database is on another machine.
To diagnose it, identify where the client runs, then check the target hostname, the port and the address on which the service listens. Do not replace localhost with a public IP without evaluating the exposure. Internal communication usually calls for a private network address or a service-specific hostname.