2

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 '18 at 19:17
  • ^ ^ Or if that doesn't work, you could try single user mode. – Wowfunhappy Oct 1 '18 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 '18 at 22:35
2

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 255.255.255.255 broadcasthost line. There's still some lingering issue about Chrome not using it, or maybe passing through to 8.8.8.8 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 '18 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. – the0ther Nov 5 '18 at 17:30
1

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

1.2.3.4 example.com www.example.com

try splitting in to two lines

1.2.3.4 example.com
1.2.3.4 www.example.com

Thanks,

  • 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 at 16:39
0
  • 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

-1

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 .