Uses of the Hosts File

How to Edit a Hosts File and Why?

Before we edit a hosts file, let's go over what a hosts file is used for. It associates hostnames with their corresponding IP addresses, allowing web pages to load properly and correctly. Editing the hosts file can block specific web pages and test a custom domain. This article goes over how hosts file works and how to edit it in multiple operating systems.

What Exactly is the Hosts File?

The hosts file is a simple text file that maps IP addresses to domain names and serves multiple purposes.

Ensuring Personal Privacy

Setting up the host file appropriately can block ransomware, banners, and other ads or 3rd party page counters.

Block Websites to Protect Kids

Edit the host file to remove websites to block for tweens, teens and children, preventing them from viewing mature content or visiting potentially unsafe pages.

Device and Network Security

Appropriately editing your host file acts as a security firewall for a PC and a more significant network. While you won't want to block all websites using hosts file, you can prevent the incursion of spyware, ransomware and blockchain sites.


When developing web applications, running the application on the local host for verification is essential for testing. Websites can run on either the localhost IP address or the IP address. Though the localhost has some limitations, You must still evaluate your webpage on the custom domain before releasing it to the public. This helps to catch and fix bugs in eCommerce payment processing gateways applications. 

Editing the Hostname file

Using Windows 8 or 10

First, you will need to find the Windows hosts file location.

Go to the Start menu and search for the Notepad application.

Right-click the icon and choose Run as administrator.

Click on File, then Open in the Notepad menu, then copy and paste the following path

This will open the hostname file.

For example, if you want to restrict on your system, copy and paste the following:

When you're done editing, save changes and exit.

Open your search engine and try to open You will receive an error stating that the page will not load, indicating that you have edited the host file correctly.


Open the hosts file using your preferred text editor in the Linux terminal window.

Input your adminstrator password when prompted.

The Linux hostname file is the same as the one found in Windows. Remove, add a custom domain, and then save the changes.


Locate the terminal application on your system; the Spotlight application makes it easy to search.

Type sudo vim /etc/hosts into the terminal, then enter administrator password when prompted.

Use the vim text editor or a different editor if you prefer. The macOS hosts file is the same as the Linux and Windows hosts files.

Make the changes, then save and close the file. If you start your search engine and attempt to access, an error message will appear.


In this article, you should have learned how to edit hosts file and the benefits of changing this file in both home and professional settings.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us