is localhost always 127.0.0.1 code example
Example: why localhost is not working while 127.0.0.1 works
127.0.0.1 localhost
127.0.1.1 vagrant.vm vagrant
# The following lines are desirable for IPv6 capable hosts
#::1 localhost ip6-localhost ip6-loopback
::1 ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.2.1 w1 w1