Reputation: 727
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.
Upvotes: 0
Views: 12548
Reputation: 43
I have solved the problem by restoring my Hosts file (it was empty):
But before, you have to check your hosts file.
cat /etc/hosts
If nothing is shown, that means your hosts file is empty.
Then just copy and paste this over the existing hosts file then save it as plain text to restore it.
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
If your hosts file is not empty, your can try to delete it and add it again with this lines.
Upvotes: 1
Reputation: 442
Probably will help for those who don't know how make Unix line endings
brew install dos2unix
sudo dos2unix -c mac /private/etc/hosts
That will convert your perfectly fine hosts file to UNIX encoding.
Upvotes: 0
Reputation: 138
I fixed it by making sure that hosts file used Unix line endings (I used Sublime Text for this)
Upvotes: 7