I add to my /etc/hosts
file this :
127.0.0.1 youtube.com
Save the file. Flush everything with :
dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Reboot my computer 30 times.
Then I run:
dscacheutil -q host -a name youtube.com
And I get :
name: youtube.com
ip_address: 216.58.220.46
Clear my cache completely since the beginning of time in any browser, go to : youtube.com
, and I get youtube.com
, not my localhost.
I'm using OS X 10.10.5, Yosemite.
Best Answer
Check your hosts file, because probably it's malformed. It should look similar to this one:
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).