I'm running the example in hiredis, which is using as the Redis server IP, and it is running properly. Actually, the redis server is running on the same machine. I know that is the IP address of lo, but how about Is it the same as


3 Answers 3



IPv4 network standards reserve the entire address block for loopback purposes. That means any packet sent to one of those 16,777,214 addresses ( through is looped back. IPv6 has just a single address, ::1.

Various Internet Engineering Task Force (IETF) standards reserve the IPv4 address block, in CIDR notation and the IPv6 address ::1 for this purpose. The most common IPv4 address used is Commonly these loopback addresses are mapped to the hostnames, localhost or loopback.

or from the RFC itself: - 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 for loopback, but no addresses within this block should ever appear on any network anywhere [RFC1700, page 5].

For fun, try by pinging:

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=64 time=0.110 ms
64 bytes from icmp_req=2 ttl=64 time=0.065 ms
--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.065/0.087/0.110/0.024 ms
  • The Wikipedia page has since changed, and now says "although any address in the range to is mapped to it", rendering the gist of this answer in direct conflict with Wikipedia.
    – Kalle
    Sep 18, 2012 at 12:06
  • 8
    @SilverSkin Would you mind explaining what you mean? The only difference between what's in answer and what's in Wikipedia now is that they (correctly) excluded and, which are network / broadcast addresses. The gist is still the same - 127.x.x.x == (except for and, which is expected on any /8 network). Sep 20, 2012 at 1:17
  • 2
    So there's no difference between binding to versus binding to So why does the hiredis bother with, if it's the just the same address? Also what happens if you did send a message to Jun 14, 2014 at 5:30
  • 8
    Need to mention that it is not the same in OS X, which only route to loopback. See here.
    – Wenbing Li
    Sep 8, 2014 at 0:54
  • 10
    @CMCDragonkai and may be on the same interface but they are not the same address. One might use an uncommon ip like if one wants to use set up a service on a common port and not interfere with other services that may be listening to that same port on Aug 19, 2015 at 3:21

I will answer each of your questions below, with references and examples. It is not as simple as Yes or No.

  • “Are all 127.x.x.x addresses restricted to the local machine?” Yes
  • “Are all 127.x.x.x addresses bound to the lo interface” Yes
  • “Are 127.x.x.x addresses routed over the network?” No
  • “Are all 127.x.x.x addresses the same?” No (depending on operating system) - 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 for loopback. As described in [RFC1122], Section, addresses within the entire block do not legitimately appear on any network anywhere. — RFC5735 Emphasis mine.

  • “Is the same as” NO According to rfc5735 it may be, but it does not have to be. This is an implementation defined behaviour. See your operating system manual. In any case the whole range is reserved, and must not be routed over a network.

While to are all local addresses bound to interface lo. They are not the same. You can use each address to bind a different service onto the same port. E.g 16 Million web-servers on port 80, only accessible from the local machine (If you don't run out of memory, or other resource first)

I have just set up a docker service to bind to I have then added an alias to /etc/hosts. Now I can connect to it via http://myserver, but not via or http://localhost. However it is only available to this machine. As it is only on the lo interface.

I then set up another docker service to bind to, and a python service on localhost:80 and another on

This may not work on all operating systems. I am using Debian(9) Gnu/Linux, Linux kernel 4.9.0-3-amd64. Some OSs may treat all addresses the same. Some may only work with

Note services such as ping will be listening on (ipv4) so ping will be received by the listener, because is one of your addresses. However if a service listens on a specific address, then you need to use this specific address to connect to it (Depending on operating system used).

see also

  • Let us continue this discussion in chat. Oct 2, 2017 at 16:20
  • It took me about an hours worth of research but I was able to finally understand what you were attempting to convey. I have updated the quote from the Wikipedia article in the accepted answer. Since the quoted statement has changed over the years, i quoted a different statement, to restore that original information the answer contained.
    – Ramhound
    Oct 2, 2017 at 17:31

Not a comprehensive general answer (there's one already). This answer of mine shows an example where was used to solve the problem.


The OP there attempted to test some software in a case when its connection to a server was rejected. This was done on the server by a temporary iptables rule that rejects all traffic from the client IP. The client was immediately able to "see" the connection was rejected.

The problem appeared when this person moved the server software to the same machine as the client and tried to use loopback interface. The rule was set to block communication from but the information a connection was rejected underwent the same rule and never got to the client software which hanged (presumably till timeout).

The solution was to use as the server address and set a rule that rejects connections to it. The information about a rejection went to and was able to pass to the client software.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy