Was there some new behavior around the /etc/hosts file in Mojave? Cannot get the thing to pick up any new entries which I make in the file. I am restarting the DNS resolver thingy, and I vetted my hosts file for weird characters using LC_ALL=C cat -vet /etc/hosts. No luck.

  • 1
    Try making a change when the Mac is booted into Safe Mode and see if the change is retained after booting normally. It is possible that some (new) process is disallowing/rolling back your changes.
    – IconDaemon
    Oct 1, 2018 at 19:17
  • ^ ^ Or if that doesn't work, you could try single user mode. Oct 1, 2018 at 19:23
  • Any chance you can show us a copy of your hosts file to make sure you're putting the entries in the correct format?
    – Jesse P.
    Oct 1, 2018 at 22:35

4 Answers 4


Looks like this is due to my records being added in the wrong place in the hosts file. I needed to put my entries above the broadcasthost line. There's still some lingering issue about Chrome not using it, or maybe passing through to for DNS if initial lookup fails. In Firefox my hosts file works as expected.

  • 1
    I can't get this to work. Mojave is ignoring host file entries. Why?
    – Jeff
    Nov 2, 2018 at 1:20
  • 1
    hard telling what the problem is, but the file I edited is at /etc/hosts not /private/etc/hosts and it was not working due to the order of entries.
    – Randy L
    Nov 5, 2018 at 17:30

If you have mapping for multiple domains in single line that might not work. example.com www.example.com

try splitting in to two lines example.com www.example.com


  • Thanks this was the problem for me because ddev was autowriting to my hosts file and appending them to a single line.
    – jerrylow
    May 31, 2019 at 16:39
  • For OS X Mavericks and later, run this command to flush DNS cache:

    sudo killall -HUP mDNSResponder

  • For OS X Mountain Lion and earlier, run this:

    dscacheutil -flushcache; sudo killall -HUP mDNSResponder


Just another tip, even though it appears that the OP didn't do the following:

Hosts file changes in Mojave will not get implemented if /etc/hosts has been made a symbolic link to another hosts file, even with the correct syntax in it. It will fail to update with the sudo killall -HUP mDNSResponder command but then does not return an error code to let you know what has happened.

Don't make /etc/hosts a symlink in Mojave.

You must log in to answer this question.

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