LightAtom

What Is a Loopback Address?

A loopback address points back at your own computer. Traffic sent to 127.0.0.1 or ::1 never leaves the machine.

A loopback address is an IP address that always refers to the local computer. In IPv4 the whole 127.0.0.0/8 range is reserved for loopback, with 127.0.0.1 the usual one; in IPv6 it's ::1. Traffic to it goes through a virtual interface (lo0 on a Mac) and never reaches the network.

How it works

An app connects to 127.0.0.1 through the lo0 loopback interface to a server on the same Mac, for example on port 3000, without touching the network.

What it's for

  • Local development: web servers, databases and APIs on your own machine.
  • Services that must not be exposed: a process listening only on 127.0.0.1 can't be reached from other devices.
  • Testing the network stack without any network.

localhost

The name localhost resolves to the loopback addresses via the hosts file: 127.0.0.1 and ::1. Which one a program tries first can matter: a server listening only on 127.0.0.1 won't answer a client that connects to ::1.

127.0.0.1 vs 0.0.0.0

A server bound to 127.0.0.1 accepts only local connections. Bound to 0.0.0.0 (all interfaces), it accepts connections from the network too, which is how dev servers get accidentally exposed on café Wi-Fi.

Other addresses in 127/8

On Linux every 127.x.x.x address works out of the box. On macOS only 127.0.0.1 is configured; others need sudo ifconfig lo0 alias 127.0.0.2.

Examples

$ ifconfig lo0 | grep inet
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
$ lsof -nP -iTCP -sTCP:LISTEN | grep 127.0.0.1
postgres  712 me  7u  IPv4 …  TCP 127.0.0.1:5432 (LISTEN)

On a Mac

ifconfig lo0 shows the loopback interface; lsof -nP -iTCP -sTCP:LISTEN shows which servers listen only on loopback (127.0.0.1 or [::1]) and which on all interfaces (*).

See it in the app

LightAtom's ports view shows every listening port and whether it's bound to loopback or open to the network.

Frequently asked questions

What is the loopback address?

127.0.0.1 in IPv4 and ::1 in IPv6. Both always mean “this computer”.

Is 127.0.0.1 the same as localhost?

localhost is a name that resolves to 127.0.0.1 and ::1. They're the same machine, but a server may listen on only one of the two addresses.

Can other devices reach 127.0.0.1 on my Mac?

No. On any device, 127.0.0.1 means that device itself.

What is the loopback range?

127.0.0.0/8, all addresses from 127.0.0.0 to 127.255.255.255.

LightAtom team

The people who build LightAtom, a network monitor for macOS.