On Fri, May 24, 2024 at 05:22:13PM +0100, Joe wrote: > Long ago, lo used to be just 127.0.0.1, which is what most people would > try to ping to check localhost, and what appeared in /etc/hosts. There > is some subtle reason, which I used to know but have now long forgotten, > why Debian started using 127.0.1.1 in /etc/hosts instead.
It's not "instead". It's "in addition". hobbit:~$ head -n2 /etc/hosts 127.0.0.1 localhost 127.0.1.1 hobbit.wooledge.org hobbit The first line is traditional. Exactly what it looks like. The second line ensures that my hostname will always resolve to a working IP address. Lots of programs need that. Some of the most common reasons back in the old days were X clients that had been told to use "myhostname:0" as their $DISPLAY. If "myhostname" didn't resolve to a working IP address (one which could contact the X server), then X client programs wouldn't work. A lot has changed since then, but the basic principle remains the same. Some programs are going to expect to be able to open a network connection to whatever IP address the system's hostname resolves to. 127.0.1.1 serves that purpose, without stepping on 127.0.0.1 which has its own legacy role to fulfill.