How To Modify Your Hosts File

Let's first start with the question "What is a hosts file?" A hosts file is a file used by an operating system to manually map hostnames to a specific IP address. The file is typically a simple plain text file named "hosts". This file is very often used by developers and system administrators during the development process for prototyping or for bypassing certain services (such as caching layers and load balancers). The hosts file is also sometimes used by certain ad-blocking programs to direct ad-serving domains to the loopback address.

Opening The Hosts File on Mac/Linux

On Linux and Mac computers opening the hosts file is quite easy. Open a Terminal and type sudo nano /etc/hosts. You'll be prompted to enter your password; once you've done that you should see something like this:

Hosts File Linux

Once you've made your changes close the file by pressing CTRL+X and then save by pressing Y.

Opening The Hosts File on Windows

First you need to run Notepad as Administrator. To do this, search for "notepad.exe" in the start menu (bottom left corner of the screen usually) or find it in "All Programs" > "Accessories". Then right click Notepad and select "Run as administrator". Once Notepad is running, click "File" > "Open" and navigate to C:\Windows\System32\drivers\etc and then select the file called "hosts" (Note, you may need to switch the file type in the drop-down near the bottom of the screen to "All Files (*.*)" in order for the file to be visible). Once you have it open you should see something like this:

Hosts File Windows

Once you've made your changes, don't forget to save: either CTRL + S or "Edit" > "Save".

How To Modify The Hosts File

Once you have your hosts file open you can start adding to it and modifying it. The basic syntax for a hosts file is a line should begin with an IP address followed by at least one space or tab followed by a list of hostnames each separated by a space. For example:

When you would save this to your hosts file and then try to access your browser would send the request to instead of looking up the IP from the DNS server.