Editing the host file with the IP address of a server that has not had a DNS url set to it will allow your apple mac or other device to access the site via the URL and have it resolve. Keep in mind that if there is already a resolve via DNS propagate through the internet this host file edit will overwrite it.


In the Terminal window, you will need to enter a command to open the Nano text editor. You will need your administrator password, as well.

  1. type sudo nano /etc/hosts and then hit return.
  2. Enter your administrator password and then hit return.

    Enter Nano text editor

You're now in the Nano text editor. You should see something that looks like this:

Map the IP address in the Nano text editor

If you want to add a new device or domain, move the cursor using the arrow keys and position it after the text in the window. Then, begin typing.

If you're mapping a particular IP address on your local network to a domain, you can type the IP address, hit tab, then type the domain name.

Conversely, if you'd like to make sure a web URL doesn't go to its intended site — if you're trying to keep your Mac away from certain sites, use "127.0.0.1." That'll map it back to your Mac. Even if your Mac is assigned a different IP address by its router, 127.0.0.1 defaults to the local machine thanks to the default settings in that hose file.

Once you're done, hold down the control and O keys to save the file, then control and X to exit.

One last step

Back at the command line, type sudo killall -HUP mDNSResponder then type return. That will flush your Mac's DNS cache, so it doesn't get confused by any changes you've made to the Hosts file.

Flush your Macs DNS cache

Don't forget you've modified the Hosts file, because at some point you may need to undo the changes you've made in order to keep your Mac working right.