What is localhost and why is 127.0.0.1 used?
Published on 2026-10-17 by frfrand
Understand localhost, 127.0.0.1, local ports, and why an application can work on your PC but not be accessible from the Internet.

Short answer: localhost is the name a computer uses to talk to itself; it normally resolves to the loopback address 127.0.0.1 (IPv4) or ::1 (IPv6). That's why http://localhost:3000 works on your PC but is useless to someone else: on their machine, localhost is their own computer.
You're programming a website and the browser shows it works at http://localhost:3000. You send that address to someone else and they see absolutely nothing. Did the application break? No. Localhost refers to the same computer from which you make the request.
This confusion is so common that it's worth understanding well once. After that, many things about networks start to make sense.
What exactly is localhost?
localhost is a name that normally points to a special address called loopback: 127.0.0.1 in IPv4 or ::1 in IPv6. That address does not look for another computer on the Internet. It tells the system: "I want to talk to this same machine."
It's like calling the internal phone at your own desk. You don't need to leave the building for the call to go through.
And the number after the colon?
In localhost:3000, the 3000 is the port. The address indicates which computer you want to reach, and the port helps identify which service should receive the connection.
You can have an application running on port 3000, an API on port 8000, and a database listening on another. It is not advisable to think of a port as a physical door that is always open: if no program is listening and there are no rules redirecting traffic, no service will respond.
Why does it work on my PC and not on another computer?
Many development servers are configured to listen only on the loopback interface. This allows testing an application without making it accessible to the entire network.
When you change the configuration to listen on 0.0.0.0, you tell a program to accept connections on all available IPv4 interfaces, but that does not mean the whole world can enter. The network, the firewall, a router, the provider's rules, and the address used still influence.
A simple way to distinguish it: - 127.0.0.1: communication with the same computer. - 192.168.x.x: a common example of private network addresses. - A public IP: an address that can be reachable from the Internet, according to routing and applied rules.
A real case: testing an API
Your frontend runs on localhost:3000 and your backend on localhost:8000. Both work on your notebook and talk to each other.
Now you upload the frontend to a platform and forget to change the backend URL. The visitor's application tries to connect to its own localhost:8000, not yours. That's why it fails even though the backend continues to work perfectly on your PC.
It's a small mistake, but it explains at once why local development and production are not the same.
Is it safe to use localhost?
It can reduce the attack surface, but it does not replace application security. A local service can still be reached by processes on the same machine and, if there is a proxy or tunnel configured, it may end up accessible from elsewhere.
Do not expose admin panels, databases, or testing tools just because "it's more convenient." First decide who needs to enter and from where.
What happens in ArduMaker?
On an ArduMaker VPS, the usual path is precisely that: the domain enters through the host's nginx, which terminates HTTPS and passes the traffic to your VPS's nginx, and that nginx forwards it to your application, which can listen only on 127.0.0.1. The public sees the website, but never the application's internal port.
In one sentence: localhost always points to the computer from which it is used. Understanding that avoids many network mysteries and quite a few hours looking for errors that actually do not exist.

Testing localhost before publishing an application
If your backend listens on 127.0.0.1:8000, you can check it from the same server with curl http://127.0.0.1:8000/. From another computer, that address points to the other computer, not to your VPS. To receive visitors, a common configuration is to place Nginx in front of the application and publish only the domain via HTTPS.
On an ArduMaker VPS you can work with this pattern: application on an internal port, reverse proxy for web traffic, and network rules that avoid exposing unnecessary services. PostgreSQL, Redis, and private panels do not need to accept connections from the entire Internet.
Also, on ArduMaker a VPS port does not become accessible from the Internet just because a program listens on 0.0.0.0: there must be a published domain or a port forwarding (TCP or UDP) created on purpose. Port forwards accept any IP by default, but they can be limited to certain addresses.
Note: 0.0.0.0 means that a process can listen on all available interfaces; it does not mean that it is safe to publish it. Real exposure also depends on the firewall, the proxy, and the network.
Frequently asked questions
Are localhost and 127.0.0.1 exactly the same? Almost always: localhost is a name and 127.0.0.1 is an address. Normally the name resolves to that address (or to ::1 on IPv6), but it can be changed in the hosts file.
What is the difference between listening on 127.0.0.1 and on 0.0.0.0? With 127.0.0.1 the program only accepts connections from the same machine; with 0.0.0.0, from all IPv4 interfaces. Whether traffic from outside arrives also depends on the firewall, the proxy, and the network.
Why doesn't my published frontend find my backend on localhost? Because the visitor's browser looks for localhost on its own computer. In production, the frontend must point to the public URL of the backend.
You will find more options for deploying applications in the ArduMaker documentation.