How to make /private/etc/hosts available on macOS Sierra? After searching related questions and answers, I find my issue still unsolved: editing /private/etc/hosts does not work on macOS Sierra.

What in my /private/etc/hosts is the following two rules.

127.0.0.1   localhost
127.0.0.1   www.yahoo.com


These two rules cannot be applied in Safari and Chrome, even after running the command sudo killall -HUP mDNSResponder. The website yahoo is not redirected to 127.0.0.1.

So what do I miss in the above operation?

And the output of ping -c 3 www.yahoo.com is as following.

PING fd-fp3.wg1.b.yahoo.com (116.214.12.74): 56 data bytes
64 bytes from 116.214.12.74: icmp_seq=0 ttl=47 time=138.418 ms
64 bytes from 116.214.12.74: icmp_seq=1 ttl=47 time=74.284 ms
64 bytes from 116.214.12.74: icmp_seq=2 ttl=47 time=69.702 ms

--- fd-fp3.wg1.b.yahoo.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 69.702/94.135/138.418/31.369 ms
If you can ping your /etc/hosts entries as root but not as regular user then try changing permissions on the hosts file to allow everyone to read. This worked for me.

sudo chmod a+r /etc/hosts