Safer and faster browsing the internet by replacing the HOSTS-file

The (video) ads shown on web pages are becoming bigger and bigger in file size and slow down the speed of browsing the internet. Because the website and the ads are downloaded from different servers, it is possible to block the ads by blocking the ad servers. This saves a lot of bandwidth, which will result in faster browsing. The most simple way to achieve this, is by replacing the HOSTS file! By placing the web servers with malware into the HOSTS file as well, it will prevent the user from downloading malicious software available from those websites.

What is the HOSTS file used for?

To be able to find a website, the dommain name in the URL must first be translated into an unique IP address. In most cases, this is done by the DNS server of the internet provider. Before the DNS server is contacted to translate the domain name in the URL, the HOSTS file on the computer is checked whether the domain name is mentioned there, because checking the HOSTS file is much faster then contacting the DNS server of the internet provider. If the domain name is mentioned into the HOSTS file, then the requested webpage will be forwarded automatically to the matching IP address.

Changing the HOSTS file

By linking the undesired website addresses (like the web servers for the shown ads) to the IP-address (the address of the computer itself) into the HOSTS file, they can be easily blocked (the area on the website for the blocked ad shows an error message which can be ignored).

Changing the IP addresses in the HOSTS file can be done by hand. Before you do so, copy the original file as a back-up to a safe location (the HOSTS file is stored in the following location: C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS, the file has no file extension!). The next step is to open the original HOSTS file with a simple text editor, like Notepad (Start, All Programs, Accessories). The default HOSTS file looks like the following lines (all rows starting wit a #  are not relevant, they only contain useful remarks):

# localhost: Needs to stay like this to work localhost

Now, a whole website can be blocked by adding a row to the HOSTS file for the main website address which has to be blocked, combined with the IP address (the address of the computer itself). In the example below is shown how it is done for the website Blocking this website is not desirable, but it shows the consequences of a blocked website in the HOSTS file when this website is tried to open in the browser.

# localhost: Needs to stay like this to work localhost

ATTENTION: So, by adding website addresses to the HOSTS file, it is very easy to block them. Besides blocking ad servers, it is also possible to block any other website (like those used by the kids). It is also possible to forward a request for a specific website to another web server in stead of the IP address of the computer itself. You can imagine that this feature can be abused, without being aware of it. This way, it is possible to easily fish for username and passwords without being able to notice it (like the website you use for telebanking, which is forwarded to a different web server which will try to fish for your login!). So, always check your HOSTS file, when there is a reason to believe that a virus or spyware could have made changes to it!

TIP: When there is nothing wrong with the HOSTS file, make sure the storage location of the HOSTS file hasn't been changed as well! The storage location is mentioned in the registry value DataBasePath (mostly with the value %SystemRoot%\System32\drivers\etc) and can be found into the following registry key:

Replacing the HOSTS file is easier

Of course, it is a lot of work to add every website manually. Fortunately, this is not necessary because an up-to-date HOSTS file with the latest threads is available for download at (the exact download location of the HOSTS file: Open the file with Notepad and copy the content (CTRL-A followed by CTRL-C), open the original HOSTS file, paste the copied text (CTRL-A followed by CTRL-V) and save the new HOSTS file (CTRL-S).

Don't forget the HOSTS file has been changed!

Always keep in mind that the HOSTS file has been changed! Sometimes, the downloaded HOSTS file contains website addresses which actually must not be blocked in your personal situation (e.g. when a login procedure uses a website address mentioned in the HOSTS file which makes it impossible to login). By restoring the original HOSTS file (temporarily), you are able to investigate whether the problems/error messages are caused by the new HOSTS file. If this is the case, the website address has to be found and deleted from the new HOSTS file (sometimes the log files of a firewall can be useful in finding the website address).

Windows 7
Windows Vista
Windows XP
AVG antivirus
Comodo Internet Security
Back-up/file Sync
Free software
Wireless network
Sharing files
Installing Windows in 10 steps
Backup data/drivers
Resizing partitions
Move personal files

2001-2022 - - SchoonePC - Rotterdam - The Netherlands