127.0.0.1

The loopback address. Whatever computer you type it on, 127.0.0.1 means that same computer, and traffic sent to it never reaches the network.

Updated November 2026 · 3 min read

The short version: 127.0.0.1 is the IPv4 loopback address: it always points at the computer you are using. localhost is the name for it. Opening http://127.0.0.1:8000 reaches a program on your own machine listening on port 8000, and if no program is listening there, the connection is refused.

Name
IPv4 loopback address
Hostname
localhost
IPv6 equivalent
::1
Reserved range
127.0.0.0/8, every address that starts with 127

What is 127.0.0.1?

127.0.0.1 is an address every computer gives to itself. The operating system handles traffic sent to it internally: nothing goes out through Wi-Fi or a network cable, so it works with no internet connection at all. Engineers call it the loopback address, because a request sent there loops straight back.

The whole block from 127.0.0.0 to 127.255.255.255 is reserved for this, though in practice almost everything uses 127.0.0.1. IPv6 has a single loopback address, ::1.

localhost is the name that points to these addresses. The mapping lives in your hosts file (/etc/hosts on macOS and Linux, C:\Windows\System32\drivers\etc\hosts on Windows), and modern systems resolve it to loopback even without that file.

127.0.0.1, localhost, 0.0.0.0 and your network IP

Four addresses that get mixed up. The difference matters most when you decide what a server should listen on.

AddressWhat it meansWho can connect
127.0.0.1This computer, over IPv4Only programs on this computer
localhostA name for loopback: 127.0.0.1, ::1 or bothOnly programs on this computer
::1This computer, over IPv6Only programs on this computer
0.0.0.0When a server listens on it: every network interface at once. It is not an address to browse toAnyone who can reach the computer, if the firewall allows
192.168.x.x or 10.x.x.xThis computer's address on your local networkDevices on the same network

Why 127.0.0.1 refuses to connect

  • Nothing is listening on that port. The address always exists, so the only question is whether a program has the port open. If none does, you get "127.0.0.1 refused to connect".
  • No port in the address. http://127.0.0.1 means port 80. A dev server on 3000 or 8000 needs the port typed out: http://127.0.0.1:8000.
  • The server listens on IPv6 only. A program bound to ::1 does not answer on 127.0.0.1. Try http://localhost:PORT or http://[::1]:PORT.
  • The server is inside a container or virtual machine. There, 127.0.0.1 means the container itself, not your computer. The app has to listen on 0.0.0.0 and the port has to be published.
  • You expected another machine. A link to 127.0.0.1 that somebody sent you opens your own computer, never theirs.
  • You typed https. A local server without a certificate answers only http://.

Check whether anything is listening

One command shows whether a program is listening on the port, and which one. No output means nothing is listening, and that is exactly when the browser says the connection was refused. The examples use port 3000: put your own port in its place.

Finding the program on port 3000 and stopping it. The process ID 48213 is an example: use the one your own command prints.

On Linux, ss -ltnp | grep :3000 gives the same answer. Add sudo on macOS or Linux to see programs owned by another user. Stopping a process ends whatever it was doing, so check what it is before you stop it.

How to fix it

If 127.0.0.1 refuses to connect

  1. Start the program you expect to answer, and read the address and port it prints.
  2. Open that exact address, port included, with http://.
  3. Confirm something is listening with the commands in the section above.
  4. If the server is in Docker, publish the port and make the app listen on 0.0.0.0 inside the container.

If you want other devices to reach your server

  1. Make the server listen on 0.0.0.0, not 127.0.0.1. Most dev servers have a --host option for this.
  2. Find your computer's network address: ipconfig on Windows, ipconfig getifaddr en0 on a Mac, ip addr on Linux.
  3. On the other device, open http://THAT-ADDRESS:PORT while both are on the same network.
  4. Allow the port in your firewall if the connection times out.

From localhost to production

A service that listens on 127.0.0.1 in production is deliberately private: a database or an application server that only the web server on the same machine should reach. That is good practice, and it also means nothing outside the machine can test it directly. From the outside you see only the public address, and whether it answers.

To test a deployed address by hand, the free bulk URL status checker shows the status code and redirects for a list of URLs, and Is Website Down checks one from several countries. Neither can see localhost: like any service on the internet, they only reach public addresses.

Deployed it? Watch the public URL.

Pulsetic is website uptime monitoring. It cannot reach localhost, but once your app is live it checks the public URL from outside your network, confirms any failure from another region, then emails you.

10 monitors free, checked every 5 minutes, with email alerts on failure and recovery. No credit card.

Sources and further reading

The documentation and specifications this guide is written from.

Frequently asked questions

  • What is 127.0.0.1?

    It is the IPv4 loopback address. On any computer it refers to that same computer, so it is used to reach programs running locally.

  • Is 127.0.0.1 the same as localhost?

    Nearly. localhost is a name and 127.0.0.1 is the address it usually resolves to. On many systems localhost also resolves to the IPv6 address ::1, so a server that listens on only one of them can answer one form and refuse the other.

  • What is the difference between 127.0.0.1 and 0.0.0.0?

    A server listening on 127.0.0.1 accepts connections only from the same computer. A server listening on 0.0.0.0 accepts them on every network interface, so other devices can connect too.

  • Can someone hack me through 127.0.0.1?

    Not from outside: no other computer can send traffic to your loopback address. A program already running on your computer can connect to it, so services that listen there still deserve a password if they hold anything sensitive.