7

I tried to use /etc/hosts file to redirect some websites to localhost. To do so, I opened it in terminal using sudo nano /etc/hosts then I modified the file, and saved it. As the last step I flushed the DNS cache with sudo killall -HUP mDNSResponder.

Here's what my hosts file looks like:

$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 somethig.com
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

This simply doesn't work. I tried to reboot, without luck. I also did a lot of research but did not find any working answers on the internet. Does the OS still use this file, or will this never really work?

I'm using macOS 10.13.

dnnagy
  • 3,711
  • 4
  • 24
  • 34

1 Answers1

0

I believe that you need to also override the IPv6 address for "something.com". Do this by adding the additional line "::1 somethig.com". So far as I can figure out, restarting Safari is also required. (You may also need to flush the DNS cache via the method you mentioned.)

Mason Lee
  • 5,130
  • 1
  • 20
  • 15