Should 127.0.0.1 and ::1 both be included in /etc/hosts file?

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 the hosts file. This is even explicitly mentioned in that very same file:

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

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 uses localhost fails.

Tags:

Hosts File