Edit hosts files on Mac

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.

type sudo nano /etc/hosts and then hit return.

Enter your administrator password and then hit return.

You’re now 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.