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

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 ( 56 data bytes
64 bytes from icmp_seq=0 ttl=47 time=138.418 ms
64 bytes from icmp_seq=1 ttl=47 time=74.284 ms
64 bytes from 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
  • Add qwertyuiop and try accessing qwertyuiop from the browsers and ping to determine if it's a priority/cache problem or the file is ignored completely.
    – techraf
    Jan 10, 2017 at 5:43
  • @techraf I update /private/etc/hosts according to your suggestion, but cannot visit qwertyuiop in browsers. The output of ping qwertyuiop is like this: PING qwertyuiop.dhcp ( 56 data bytes and Request timeout for icmp_seq 0. It looks like that is redirected to
    – waleking
    Jan 10, 2017 at 5:59
  • @waleking Please check the file /etc/hosts with ls -la /etc/hosts. It should show something like this: -rw-r--r-- 1 root wheel - 214 29 Aug 22:30 /etc/hosts (with a different size - here 214 bytes - and date of course). If the file doesn't exist or can't be found, a suffix was added probably...
    – klanomath
    Jan 10, 2017 at 6:57
  • @klanomath yes, the output shows the file /etc/hosts exists: -rw-r----- 1 root wheel 71 Jan 10 13:50 /etc/hosts. But this file does not work.
    – waleking
    Jan 10, 2017 at 8:28

1 Answer 1


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
  • Yes, it works for me after I use your command and reboot my mac. Thanks so much, it puzzled me for a long time.
    – waleking
    Feb 22, 2017 at 20:38
  • On 10.13.6, ping uses the hosts file address, but Safari and Firefox still get DNS from the outside.
    – WGroleau
    Aug 29, 2018 at 17:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .