OSX Sierra hosts file is ignored

Look at System Preferences -> Network

If the currently active "Location" has one or more DNS servers listed then the system will create the file "/etc/resolv.conf" which will list those nameservers as the place to go for resolution, bypassing /etc/hosts entirely

resolv.conf is created dynamically by "Network" prefs, and overwritten based on the "DNS Server" field of the currently active "Location" or removed if that field is blank


The file might be corrupted/damaged, it has to be an ASCII file. You should recreate it:

  • move the old file with mv -f /etc/hosts /etc/oldhosts
  • create a new file with nano
  • populate it with the values of the old file
  • save it as /etc/hosts

That should do it.


Also, make sure your list of hostnames doesn't exceed 20 names. I frequent a site which likes to put advertisements in your face, so I assign the FQDN from the popup as an alias of localhost. Recently I found my hosts file wasn't working. Seems the limit is 20 hosts... Example:

127.0.0.4 www.slutroulette.com static.exoclick.com www.gameskwala.com www.thefreecamsecret.com www.slutroulette.com cdn1.adexpert.com cdn2.adexpert.com cdn3.adexpert.com cdn3.adexperts.com abine.com www.abine.com e1.static.hoptopboy.com.rncdn1.com gameinvite.24trk.com main.exoclick.com 0427d7.se syndication.exoclick.com 0427d7.se gamingruff.com www.gamingruff.com mackeeperapp.zeobit.com 
127.0.0.5 ads.adplxmd.com mackeeperapp3.mackeeper.com onclickads.net onclick.net fundownloads108.com pussl10.com rumorsleague.com kitsfilesdll.com pussl8.com nowsetup.enterworldofupgrading.review playgr8.com autoupdate.thebigandgoodfree4upgrading.trade om.elvenar.com www.hitcpm.com www.ibtimes.co.uk mysagagame.com

Tags:

Hosts

Mac