How to make changes to Mac OS hosts file take effect?
I frequently edit my /etc/hosts file to block access to distracting websites when I'm trying to work (e.g. I'll add a line like 127.0.0.1 ).
Until recently, changes to the hosts file seemed to take effect immediately (my next attempt to visit would be redirected to localhost); however, suddenly, these changes don't seem to be taking effect. I'm not sure what has changed on my system, except for possibly a minor OS update.
Is there a way to make hosts file changes active, short of restarting my machine? This site suggests running sudo killall -HUP mDNSResponder but this hasn't worked.
I'm on Mac OS 10.15.3.
1 Answer
Depending on how big your hosts file has become, it can take time for mDNSResponder to sift through it and block the sites or domains you don't want to see.
You can also install a browser extension that will do that for you from within the browser, not system-wide, with less overhead.
You must have a good reason not to restart your Mac, but sometimes it's the only way, short of purging RAM and VM with the "sudo purge" command in Terminal, and you need to install an osax that requires XCode installed to allow this command to be recognized by bash first.
"purge" is kind of deprecated in recent versions of macOS, but it still does the job, provided you can make it work.
Or... You can reboot your machine every once in a while...