Apple - /etc/hosts will not update/refresh at all

Check your hosts file, because probably it's malformed. It should look similar to this one:

##
# 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
127.0.0.1       youtube.com
127.0.0.1       www.youtube.com
255.255.255.255 broadcasthost
::1             localhost
 

Opening the file with sudo nano /etc/hosts it should have a trailing empty line. All entries for 127.0.0.1 should be added above the broadcasthost. The space between IP-address and hostname should be one tab: .

After writing the file to disk with nano, the changes should take effect immediately (usually without executing any dnscacheutil or killall commands). Check this with ping youtube.com.

Google Chrome is (probably) the only app which doesn't adhere properly (as a test in a VM revealed).


sudo killall -HUP mDNSResponder

No reboot required.

"It works!" for me, OS X 10.11.6

Tags:

Macos

Dns

Hosts