add following line in the file
Edit the nsswitch.conf file vi /etc/nsswitch.conf and change the hosts line to read:
“hosts: dns files”
Which means, for programs that want to resolve an address. They should use the dns feature first, and the /etc/hosts file if the DNS servers are not available or can’t resolve the address.