How to edit the Hosts file in Windows 10

There are times when you want to change where a certain domain URL points to without making changes to your private or public DNS server. The easiest way to do that is using the hosts file in Windows 10 and other operating systems.

Short History of Hosts file

Before 1984 there were no domain name systems ( DNS) so the only way computers could translate hostnames to IP addresses was by using a text file called hosts.txt.  the hosts file was manually maintained and shared via the ARPANET network at the Stanford Research Institute. Once the process of translating hostnames to IP addresses was automated through a domain name system (DNS ) the hosts file sort of lost its usefulness. Most people are not even aware that such file even exist in their computers, but operating systems still include it because sometimes it can become handy.

Editing the Hosts file

In Windows 10, the hosts file is located at this path C:Windows\System32\drivers\etc or whatever drive your OS is installed at.


The file is locked by the operating system so you can’t edit it directly, at least not with notepad. So download one of these text editors  or to edit the file directly. after you have installed one of those editors, right-click the “hosts” file, and click on  open with, and choose the editor you just installed:


By the default the hosts file does not have anything enabled.  for example, if I want the URL of this blog to point to a different site, the for example, I would enter that information like this:


and when you type the URL on your browser you should get this:


kind of creepy don’t you think? yeah, I thought so too.

Edit the hosts file in Linux and Mac

In Linux including Android, and in Apple computers the hosts file is located at this path etchosts so to edit that file in Ubuntu for example you will just type this

sudo nano /etc/hosts


The hosts file in Linux and Windows is the same so you edit it the same way.

Blocking Ads with the Hosts file

So far I have just covered the basic function of the hosts file, but you can do some advanced things with a hosts file, like blocking ads in your browser for example. I know there are ad blocker extensions you can install in Firefox and Chrome, but IE and Edge don’t support extensions yet, so if you want a universal ad blocking mechanism the hosts file is the route to go. go to this URL and follow the instructions on how to use the hosts file to block ads.


Using the hosts file in Windows 10 and other operating systems to point URLs to a different IP address is really handy sometimes. I use the hosts file in Windows 10 all the time when working on new websites that haven’t gone live yet.

More Windows 10 Tutorials