Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm almost positive everyone on here knows the meaning of 127.0.0.1. But, why is that ALWAYS localhost? Who picked that arbitrary IP? Why was that IP picked? Why not something more simple such as 1.0.0.0? Is there some special meaning to 127.0.0.1?

share

locked by Chris S Feb 6 at 16:10

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

3  
Seek and ye shall find the RFC –  SpacemanSpiff Apr 25 '13 at 23:31
    
@SpacemanSpiff RFC? –  James Graham Apr 25 '13 at 23:34
4  
RFCs (Request For Comments) are the basic building blocks of the Internet. See my answer below for more. –  Michael Hampton Apr 26 '13 at 0:07
comments disabled on deleted / locked posts

2 Answers

up vote 41 down vote accepted

Jon Postel picked 127.

Before the Internet Assigned Numbers Authority took over (RFC 3232) around the time of his death (RFC 2468), he was the "czar" of Internet address and port assignments, having essentially nominated himself for the task. (RFC 349)

Back in the early 1980s, when IPv4 as we know it was first being hashed out, existing networks were given "class A" address blocks in the 32-bit address space that would go into effect in 1983 (RFC 801). Both the initial assignments and the 127 assignment you ask about, as well as the first definitions of "class A", "class B" and "class C" IP addresses, were first published in Postel's RFC 790. (Note that "classes" were superseded by CIDR in RFC 1519, now RFC 4632.)

In RFC 790, Postel defined 127 as "reserved".

      127.rrr.rrr.rrr                 Reserved                     [JBP]

Its first formal definition appears in RFC 990, where it is defined as follows:

The class A network number 127 is assigned the "loopback" function, that is, a datagram sent by a higher level protocol to a network 127 address should loop back inside the host. No datagram "sent" to a network 127 address should ever appear on any network anywhere.

And again in RFC 1060:

(g) {127, <any>}

Internal host loopback address. Should never appear outside a host.

Thus, any address within 127.0.0.0/8 is to be considered loopback and be routed back to the local host.

The current list of special-use IPv4 addresses is RFC 6890, which obsoleted RFC 5735, which in turn obsoleted RFC 3330. RFC 5735 states:

127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher-level protocol to an address anywhere within this block loops back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback. As described in [RFC1122], Section 3.2.1.3, addresses within the entire 127.0.0.0/8 block do not legitimately appear on any network anywhere.

Finally, in any IPv4 subnet, the lowest address is not usable as it represents the network route. So the first usable address in the subnet, and therefore the most commonly seen, is 127.0.0.1.

share
add comment

From the RFC:

127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher level protocol to an address anywhere within this block should loop back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback, but no addresses within this block should ever appear on any network anywhere [RFC1700, page 5].

From wikipedia:

As with all IP addresses, defining a synonymous hostname simply makes life easier for human users — and localhost is the alias networking pioneers settled on.

Also note that 127 in binary is 01111111, the reversed and inverted value of 1 (00000001)

share
4  
Thank you! I would vote up. But, alas, my reputation is that of a child. –  James Graham Apr 25 '13 at 23:49
7  
Er, 10000000 (128) is the not of 01111111 (127). "Opposite" isn't a bit-wise operation and makes no sense in such a context. –  Chris S Apr 26 '13 at 0:06
    
I suspect the bitwise values of the addresses is circumstantial and has no authoritative meaning in the choice of 127 being the loopback network block. –  Matthew Ife Apr 26 '13 at 0:36
6  
@Mlfe the bitwise value of 127 is not circumstantial: it's the "last" class A address, which all have a leading bit of 0. –  Michael Edenfield Apr 26 '13 at 1:24
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.