3 Ways To Take Advantage Of Your Hosts File [Windows]


All Windows systems contain a “hosts” file that allows you to associate certain IP addresses with a domain name. This file is read and interpreted by the DNS client service in Windows. It’s the first priority in defining what your computer connects to when you type a domain name on your address bar or connect to a domain name through any other program, such as uTorrent. The “hosts” file overrides any request to a DNS server for a domain name resolution, meaning that you can override where your computer connects to by editing this file as you wish. Today, I’m going to teach you how to take advantage of this file in some ways that might make your life much more convenient.

First Things First: Editing The Hosts File

If you didn’t know what the hosts file was, or have just a minimal idea about it, chances are you don’t know how to edit it. This is simple:

  • Navigate to “C:\Windows\System32\drivers\etc” and look for a file that says “hosts.”
  • Right-click it, hover the mouse over “Open with,” and click “Notepad.”
  • There you go!

The syntax for editing the file is shown in the example. You type the IP address first, leave a space, and then type the domain name. For example, if I want Windows to connect to my local IP address to reach Google (I don’t know why you’d want to do that), then I’d type “ google.com.” That was easy, wasn’t it? Now, let’s get to the ways you can take advantage of this little method.

1: Substitute One Domain Name For Another

This one’s a very useful trick, in the sense that you can control what websites a computer accesses through this file. If you have someone in the household accessing a site you don’t want them to see, you can associate it with another IP address, leading the person to another website. Let’s say you want to redirect someone from Google to Yahoo. First, you must get Yahoo’s IP, since that’s the destination. Click the “Start” menu, type “cmd” on the bottom text box, and press “Enter.” This takes you to the command prompt. After that, type “nslookup yahoo.com“. You’ll get something like this:


Notice how there are three IP addresses. Don’t panic. In your hosts file, add just one of the three. So, you’ll end up writing something like:

After you’ve saved the document, Google’s domain name will open Yahoo’s website.

2: Block A Site Entirely

Every computer has a local address. This address allows you to connect to open ports on your own PC. If you’re not running any web services, then you will get a rejection when typing the address on your browser. This address, “,” is a powerful way to block websites. To block any website on the hosts file, just type the local address, type a space, and then type the domain you want to block. If you want to block Facebook, for example, type “ facebook.com“. That’s it!

3: Create A Short-Hand Name For A Domain

This technique will transform anything you want into a valid domain. For example, you can type “face” to connect to Facebook. As in the first section, you must find the IP of the website first. Follow the same steps as in section 1, but type a short name for the domain. You can type something like “ fa.ce” in a hosts file entry and you can now use “fa.ce” to connect to Facebook.

Any More Ideas?

I think I pretty much covered everything, but if you feel you have found something that’s useful and wasn’t covered in here, comment below. Don’t hesitate to ask questions if you’re stuck anywhere!

Miguel Leiva-Gomez Miguel Leiva-Gomez

Miguel has been a business growth and technology expert for more than a decade and has written software for even longer. From his little castle in Romania, he presents cold and analytical perspectives to things that affect the tech world.


  1. Great piece of advice. But if you are using Windows 8, you won’t be able to edit the HOSTS file by using regular method mentioned in the article. Here are some ways you can use to edit the HOSTS file in Windows 8 without any problems:

Comments are closed.