Edit hosts File on Windows 10

While Domain Name System or DNS is mostly used for this function (being a centralized and half-automatically managed name resolution system), the HOSTS file can be used as a local name resolution mechanism, and when used in conjunction with other name resolution mechanisms such as DNS, the HOSTS file takes precedence over them. In short, your host file is a form of DNS. Your computer actually looks for your host file before hitting the internet and finding the site you’re searching.

1 Edit hosts File on Windows 101.1 Location of the Hosts File1.2 How To Edit Hosts file1.3 How the Hosts File Works1.4 Redirect a Website Using Host File1.5 Create Website Shortcuts using the Host file1.6 Block websites using host file windows 101.7 Remove malicious entries set by malware1.8 Lock Hosts file to prevent hijacking

Location of the Hosts File

In Microsoft operating systems, the HOSTS file is located in the following location: C:\Windows\System32\Drivers\etc

How To Edit Hosts file

Some Times we need to edit the Hosts file, For Different purposes like custom domain redirection, block certain websites, or remove malicious entries set by malware. We can modify the host files using Notepad but, As This is a system file we cant modify this with a normal user account, We need administrator rights. For this, we need to open Notepad As ( Admin )

On Start menu search type notepad,Right-click on a notepad and select Run as Administrator.Here on note pad click on file Select openBrowse for the following path: C:\Windows\System32\Drivers\etcHere Select All Files from the drop-down menu and double click on the host’s file.

This will open Host files As Shown Bellow the image.

Note: To modify the host file, you need to add two entries, including the IP address of the remote host or application to the friendly address you want to use. for example: Type the IP address of the remote host or localhost followed by the domain or computer name you want to use to reach the device or application. Then click on File, and select Save.

How the Hosts File Works

The Host File contains lines of text that are made of IP addresses followed by one or more hostnames or fully qualified domain names (FQDNs). Each field is separated by white space (blanks or tabulation characters). For example, if you wanted to use the HOSTS file to translate a hostname of a computer called “FTPserver” into the IP address of 192.168.1.100, Then We need to Add the Bellow line: The HOSTS file can also translate Fully Qualified Domain Names (or FQDNs) of computers, such as ones used on the Internet. For example, if you wanted to add a manual line to translate an FQDN of a computer called “webserver.domain.com” into the IP address of 11.06.23.100 you would add this line: When you ping it, your computer will resolve the name to the correct IP address:

Redirect a Website Using Host File

You Can Redirect Any Website to Another website by modifying the Host file. For Ex: you want To Redirect YouTube.com to Twitter.com This means when you open Youtube.com on your web browser it automatically redirects to twitter.com. For this first, we need Twitter’s IP address. we can get this by using the ping command. Open the command prompt, type ping twitter.com -t and hit enter key you will see the twitter.com numeric IP address.

Now on the Host file Add the Twitter IP Space and The Domain Name

This line tells our computer to connect Youtube.com to Twitter’s IP address. Type Youtube.com you’ll end up on Twitter!

Create Website Shortcuts using the Host file

You can also modify the host file to create “shortcuts” that quickly access websites from any program on your computer. For example, if you’re a Twitter addict, you can associate “t” with Twitter – type t in any web browser’s address bar and you’ll instantly end up at Twitter. You can also create shortcuts with multiple letters, such as twit. You don’t need a .com, .net, .org, or any other type of extension. However, you can’t use spaces. To do this, just add the following line to the host’s file and save it:

Now you can type t into any program’s address bar and you’ll end up at twitter.com.

Block websites using host file windows 10

If you want to block your computer from accessing certain websites, you can use the loopback address (127.0.0.1) followed by the domain name (e.g., 127.0.0.1  website.com) simply add the following entry on the Host file and save. 127.0.0.1    blocksite.com Ex : 127.0.0.1 facebook.com 127.0.0.1 youtube.com

Remove malicious entries set by malware

Also Sometimes Due to Virus / Malware infection you may notice certain Websites not open on your computer. This is Because malware automatically edits your Host file and makes Different entries for Domain Redirection (Ex: Any domain Name automatically Redirects to a specific Website ) or Blocks some websites. Simply open the Host file on Notepad and Clear Other entries set by Malware adware. And left the default entries as shown below the host file.

Lock Hosts file to prevent hijacking

As some times malware/ Adware redirects web addresses by altering your host files. A good latest updated antivirus can prevent this hijack but if you want to add another layer of security then the second option is to lock the host’s file so no other program or user except you can rewrite it without unlocking it. To prevent Host file hijacks, you may navigate to it, right-click on it, select Properties and make it a Read-only file. This will lock down your Host’s file and prevent anyone or any malware from writing to it.

That’s All About edit hosts file on Windows 10. Note that after making any modification on Host files Restart windows to take effect the changes you have done. I hope now you can easily Modify, Edit the host file on Windows 10 to Custom Domain Redirection, Block Different Websites, etc. Feel any Difficulty while edit host files discuss in the comments below. Also read:

What is the Difference Between IPv4 and IPv6 Protocols? ExplainedWhat Is The Difference Between A VPN And A Proxy and how do they work?Fix WiFi doesn’t have a valid IP configuration Windows 10, 8.1 and 7Solved: DNS_probe_finished_no_internet windows 10 Google chrome. How to block websites using host file on windows 10  Updated 2022  - 65