Search code examples
macoshosts

ping: cannot resolve localhost: Unknown host OS X


127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost 
fe80::1%lo0 localhost

This is my /etc/hosts file but it's really strange failure to ping and cannot resolve localhost.

It's work well like ping gonjay when I add

127.0.0.1 gonjay

to my hosts file.


Solution

  • I fixed it by making sure that hosts file used Unix line endings (I used Sublime Text for this)