How to edit your hosts file

Windows

Assuming the Windows boot drive is C:, the hosts file is located in the following path: C:\Windows\System32\drivers\etc\hosts. 

You can use any text editor you like, such as Notepad, to edit the hosts file. The editor must run as administrator, like this:

windows-notepad-run-as-administrator

In Notepad, click File > Open, follow the path above and open the hosts file. Make the necessary changes and save the file.

macOS

In macOS, the hosts file is located at /etc/hosts. You can edit it directly in the Terminal using any text editor you want. In the example below we use Vim. It is important to open the hosts file as root. Open a terminal window and type the following:

sudo vim /etc/hosts

os-x-terminal

Make the necessary changes and save the hosts file.

Unix / Unix-like

As in macOS, the hosts file is located in /etc/hosts in Unix and Unix-like operating systems. Similarly, the hosts file can be edited in the terminal with your text editor of preference. Using the same example as above, type the following in a terminal window.

sudo vim /etc/hosts

Make the necessary changes and save the hosts file.