How-To Geek

Use a Free Tool to Edit, Delete, or Restore the Default Hosts File in Windows


The hosts file in Windows contains mappings of IP addresses to host names, like an address book for your computer. Your PC uses IP addresses to find websites, so it needs to translate the host names into IP addresses to access websites.

When you enter a host name in a browser to visit a website, that host name is looked up in DNS servers to find the IP address. If you enter IP addresses and host names for websites you visit often, these websites will load faster, because the hosts file is loaded into memory when Windows start and overrides DNS server queries, creating a shortcut to the sites.

Because the hosts file is checked first, you can also use it to block websites from tracking your activities on the internet, as well as block ads, banners, third-party cookies, and other intrusive elements on webpages. Your computer has its own host address, known as its “localhost” address. The IP address for localhost is To block sites and website elements, you can enter the host name for the unwanted site in the hosts file and associate it with the localhost address. Blocking ads and other undesirable webpage elements, can also speed up the loading of websites. You don’t have to wait for all those items to load.

The default hosts file that comes with Windows does not contain any host name/IP address mappings. You can add mappings manually, such as the IP address for As an example of blocking an ad server website, you can enter the following line in your hosts file to block from serving you ads.

NOTE: You can use the entries in the hosts file to block entire sites, not portions of sites. If there are ads served to you by the site you are viewing, they cannot be blocked without blocking the whole site.

To manually add entries to the hosts file, you can open the file (C:\Windows\System32\drivers\etc\hosts) in a text editor like Notepad.

NOTE: The hosts file has no extension.

However, an easier way to edit the hosts file is to use a free tool called Host Mechanic. This tool allows you to add entries to the hosts file, revert back to the default hosts file, and delete the hosts file.

Host Mechanic does not need to be installed. Simply extract the .zip file you downloaded (see the link at the end of this article) and double-click on the Host Mechanic.exe file.


If the User Account Control dialog box displays, click Yes to continue.

NOTE: You may not see this dialog box, depending on your User Account Control settings.


To add an entry to the hosts file, enter the host name for the site in the Site edit box. If you’re entering a site you want to block, click the check box. Otherwise, enter the IP address for the site in the IP Address edit box. Click Add to Host.


The following confirmation dialog box displays. Click OK to close it.


If you scroll down in the Host File Content box, you’ll see the new entry at the bottom of the hosts file.


To revert back to the default hosts file that came with Windows, click Restore Default Host File.


Another confirmation dialog box displays.


NOTE: All your changes to the hosts file are removed, and the host file is empty again, except for the commented instructions for its use.


The hosts file may get hijacked by malware programs, that insert entries directing your computer to their webpage. If this happens, you can restore the default hosts file. However, if this doesn’t work, you can delete the hosts file by clicking Delete Host File in Host Mechanic and then create a new one in the C:\Windows\System32\drivers\etc directory. See Microsoft’s page about resetting the hosts file for the initial text that should be in the default hosts file for the different versions of Windows (XP, Vista, 7, Server 2003, and Server 2008).

NOTE: Remember the hosts file should just be named “hosts” with no extension.


Once you delete the hosts file, the following confirmation dialog box displays.


To close Host Mechanic, click the X in the upper, right corner of the window.


Download Host Mechanic from

NOTE: When using Host Mechanic, you might see a malware warning message. The AskVG website, who provides this software, says it’s a false positive. It modifies a system file, so some security software programs might incorrectly detect it as being suspicious. However, it seems safe to use.

For more information about ways to edit and use the hosts file, see the following articles:

You can also download a ready-made hosts file that contains entries that will block most major parasites, hijackers, ad servers, and unwanted adware/spyware programs.

Lori Kaufman is a writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 11/28/12

Comments (16)

  1. Huseyin

    Is there anyway to assign one host file for a group of workstations so that host file can be maintained at a server and be easily edited by management?

  2. TheFu

    @Huseyin – what you want is a centralized DNS solution. Many home routers will do this as will DD-WRT, OpenWRT and Tomato. Of course, you could install a DNS server for your LAN and have the DHCP server provide it to all DHCP clients.

    Or you could setup an automatic push using whatever built-in rsync-like tools your OS supports.
    Or you could setup automatic file pull using a login script for your OS.
    Both of these last 2 answers will probably run into permission issues, depending on the OSes involved.

    If you choose to run a DNS server for your LAN, you should know that one of the most likely services to be hacked from the internet is DNS, so be certain that you do not allow external queries or access to that service unless you are a professional. I’m certain lots of readers here will claim to have run DNS for years without issues – I did too. Then my DNS was hacked over a decade ago. The hack was uncovered within a few hours and corrected, but during that time, all SSL/HTTPS connections would be suspect. That is a huge risk these days.

    Be cautious about this. I’m just sayin’.

    For more reference, Lifehacker has an article about blocking ad networks using hosts files that I like. FYI, I was the author. ;)

  3. jasray

    Question: If the computer first looks for an address on the local computer host file, does that mean one can modify a host file to allow blocked sites by adding them to the host file on the computer or by using a modified host file on a portable device with a portable browser?

    Since the computer will be searching for the address on the local machine first, the request would never go to a DNS which, in theory I guess, would mean blocking the IP would be impossible. Yes? No? Maybe?

    In other words, if one can block sites via the host file, can one also open sites via the host file?

    Purposeful redirects as well? Sounds like an easy way to really screw up a network–replacing host files all over the place.

  4. bobby.tables

    In my opinion HostsMan is even better and still just as easy to use. You can find it here:

    Why it is better? It can automatically download several well known hosts files for ad-blocking etc. Also it provides an HTTP Server (with a very low footprint) so the browser gets a correct 404 error for missing ads or scripts. And last but not least it gives you the option to temporarily disable the edited hosts file and use the default one for situations where e.g. you would need to see a blocked ad just this one time.

  5. Mister Know-IT-all(most)

    @ Huseyin:

    Editing the hosts file is probably the simplest and often overlooked ways to reroute or even block certain web “addresses.” Notice I didn’t say IP addresses! So if you want to block certain web addresses for all people on your own network, it might be easier to set up your own DNS server or changing who your public DNS server is to someone other than what your ISP has you using. The only caveat there is that you probably will need to have a static IP address assigned to you from your ISP. That way, your new DNS service (someone like OpenDNS) knows that all traffic is from you and your LAN. (FYI: Most home users don’t usually have static IP addresses since it’s usually a feature you pay extra for. And even though dynamically assigned IP addresses also don’t appear to change – sometimes for years – they can and sometimes do!)

  6. Stephen


    You could set up a share with proper permissions for the workstations to access and create a script that compares the local hosts file with the remote hosts file and if different copy the remote one to local. Then create a scheduled task to periodically run the script.

  7. Mister Know-IT-all(most)

    @ jasray:

    YES! You can get past some blocked web sites if you edit the hosts file. But why do that? If you already know the IP address of a site you want to visit then just use that IP address instead. No mucking around with anything! For example, typing in “” (without the quotes) into your browser’s address field instead of “” you should almost instantly be looking at Google’s main web page. Done!

    As far as any web address “lookup” goes, the sequence of “queries” is really pretty straight forward. Type something into your web browsers address bar and it immediately looks at the systems HOSTS file (which Lori said was nothing more than a text file without a file extension). Failing that, the query then goes to a local DNS server on your LAN which probably doesn’t exist and finally it looks for an external DNS server out on the Internet somewhere. That last query should eventually get something since all ISP’s will provide some sort of DNS address even if you don’t specify one.

    So even if you use a portable browser, it will still look at the system’s “HOSTS” file on the actual computer before it looks for a DNS server. If you want to get past this, like I said, just type in the IP address directly. Because the entire purpose of the HOSTS file or even a DNS server is to return an IP address whenever a web address is typed in. In many ways, this whole process is just like a phone book! The only question is, whose phone book do you want to use? Or do you know the number by heart?

  8. Hector

    Sound like a tool for doing something that doesn’t need a tool. For years I’ve used Notepad to edit the hosts file.

  9. Mister Know-IT-all(most)

    …and Notepad would work just fine. But do you know what to edit and how? This tool does have some merit. But for the serious geek it’s probably not worth it.

    I still like the article though. I particularly like the idea of redirecting bad/objectionable site names to the local IP address ( as a way of blocking. So if you’re tired of all those advertisement boxes with potential bad code (albeit mostly java script) littering everyone’s web page, redirecting those URL’s to the local IP seems almost ingenious. I wish I could remember these tricks cause taking a web site URL like (which is a pure nuisance if you ask me) and redirecting it to the local IP was worth every second I took to read the article.

    But sure. This isn’t really “blocking” either. There’s still the matter of web site IP addresses where you can bypass the whole hosts file and any DNS lookups if you know IP addresses of the sites you want to visit. But how many people even know what an “octet” is?! (Probably everyone here does.)

  10. Ron

    Personally, I prefer HOSTSMAN ( ).

    It allows you to use an integrated editor or notepad. But more imporantly, it connects to several sources of “blacklists” that you can download and integrate into your hosts file. You can pick which sites you want to download lists from.

    There are also more features like temporarily disabling the hosts file and flushing the DNS cache.

  11. bedlamb

    I was considering editing the hosts file to include the list of adware sites, but after looking at the special instructions on the website, I was pretty sure I’d end my day by re-loading Windows.

  12. Nixonshead

    Great Post. I wondered what other Host file Managers were out there. I use Hostman and the MVPS host file you provided a link for at the very bottom of the story above. I also use MVPS in Linux Mint or Ubuntu. Works just as well, except there’s no photo where the blocked ad WAS. MVPS has great instructions on how to install on all Windows versions, Linux and MAC. They’re also recommended by the Kim Komando Show. I wish Linux had a better program for this LIKE HOSTMAN. They do have “domain blocker” which lists the site block as instead of BUT you can only put in ONE site at a time. Hostman in Windows allows for a large number at once and auto updates from MVPS or other sites you could choose. For those worried about Host file breaches in Windows? Zone Alarm software Firewall and WinPatrol have tabs that LOCK the HOST file. If you wanted to add to the list, it would prompt you before you or anything else Could change it. I’ve used the Host file in Linux/Windows for years and and am thankful for everyone’s efforts to provide us with a great added layer of security.

  13. Paul O' Sullivan

    Now do one on changing the changing the proxy used on the computer using the registry.
    since it’s blocked on limited accounts,but I haven’t met a computer with regedit disabled on 7+ yet.

    if you chose to export the file, even deepfreeze wouldn’t stop it

  14. Mark

    I personally use a free software called Qustodio at home. Light weight and easy to use, it is a complete solution with automatic blocking and real time reporting of time and sites visited. Also, you will be able to view this data for 30 days. It’s pretty straight forward. The site is

  15. Matt

    I’ve read that if your HOSTS file gets too big, it slows down your internet instead of speeding it. Is it true? What is the maximum size of a HOSTS file to maintain it effective?

  16. Hackerpunk1

    Nice, my application got featured on How-To-Geek :D

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!