Hosts file plays a vital role in networking. You can compare Hosts file with the Phone book of your phone. When you want to call someone from your phone book you just click on the name of the person, you want to call. You do not need to remember the phone number of that person at all. Because, the number is already stored in your phone book. Hosts file serves the same purpose. It may sound that I am talking about DNS (Domain Name Server).

But Hosts file is definitely different from DNS.


Each and every website has at least one Global IP address. I am saying “at least one”, because sites like Google, Facebook, Yahoo, and MSN have a lot of servers all over the world to provide users fast and most relevant results. To access a site from your computer you need to send a request to its IP address. But it is very much difficult to remember all the IP addresses. DNS (Domain Name Server) handles that job. Then, what’s the role of Hosts file?
To discuss that first you need to have an idea on how your computer connects to the website, that you have entered into your Web-browser’s address bar.

Connecting through the Internet to a website

Whenever you type a Web address, i.e., in your web browser, your computer first consults with your Hosts file. You can find your Hosts file in


location. C:\ may vary according to your OS root drive. Default Hosts file looks like following:

Default Hosts File

Your computer first searches whether there is any IP address for that web address(domain name) in your Hosts file. If there is no entry for that web address in theHosts file then only your computer sends a query to a DNS (Domain Name Server) to resolve the IP address for that web address.

Suppose you do not have any IP entry for in you Hosts file (Generally we don’t have). So, if you type in your web browser, your computer will send a query to DNS to resolve its IP address. Once it get the IP address of from DNS, your web browser will be connected with that IP address and web page will start loading. Now, the question is, if you put an arbitrary IP address (Which is not the actual IP address of for entry in your Hosts file, what will happen? Let’s check the situation with an example.

Open your Run window and type cmd to open Command Prompt. Now, type ping and hit Enter. Thus you will get the IP address of For me it is

Ping Google

Now you need to edit your Hosts file. To do that, first you have to Take Ownership. Now, open the Hosts file with notepad or notepad++ and add the following line is the IP address of

Facebook is masked

Now, if you type in your web browser and hit enter, you will see your browser is loading The reason is quite clear. You have created an entry for which has the IP address of in your Hosts file. It proves that computer first searches its local Hosts file to get the IP address for a Web address. If it does not find the web address in the Hosts file then only sends a request to DNS to find the IP address of that web address. So, Hosts file has priority 1 and DNS has priority 2. So, this Hosts file is powerful enough to musk original DNS entry and you can assign an IP address of your wish for an entry. You can also configure host file to block any website or IP.

Hope, you have enjoyed reading. Feel free to share you own views.


Nick is a Software Engineer. He has interest in gadgets and technical stuffs. If you are facing any problem with your Windows, feel free to ask him.


  1. […] DNS can convert the IPv4 or IPv6 address into meaningful names and then can convert them back into IPs. The process of translating the IP addresses into names consumes time which causes delay. Moreover when the DNS servers are down we can’t access the site thorough their URL’s. Hence it becomes necessary to make a mapping of the hostnames to IP addresses. This is the sole job of Windows HOSTS File. […]


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.