I am new to unmanaged VPS servers and in addition IPv6. Is it necessary to include 127.0.0.1 AND ::1 for localhost in /etc/hosts files for IPv6 enabled servers, or is ::1 alone enough?
I am new to unmanaged VPS servers and in addition IPv6. Is it necessary to include 127.0.0.1 AND ::1 for localhost in /etc/hosts files for IPv6 enabled servers, or is ::1 alone enough?
Yes, 127.0.0.1 should be left. IPv6 is enabled, but IPv4 is still used.
You didn't mention which OS you are using.
On Windows systems, the name resolution of
localhost
is handled by the system and those entries are not needed in thehosts
file. This is even explicitly mentioned in that very same file:Leave the hosts file alone. Fiddle with it and you may break something. For example, if you remove the
127.0.0.1
don't be too surprised if anything that useslocalhost
fails.Adding anything to /etc/hosts is not necessary, but really helps, so it will be pretty useful to add both (IPv4 and IPv6) records. After all, it is not expensive in any sense (10 seconds on each won't kill you day), but you'll know this part is done completely.
On my mac, I could not access localhost. When I commented out the line "::1 localhost", I was able to access localhost again.