What is a Hosts file?

The hosts file serves as a local DNS server for the computer and is used to map IP addresses to domain names. The hosts file is essentially the first place your computer looks for an IP address when you are browsing through the internet. It is a file found on your computer that contains the name of a website and its corresponding IP address. When you type in “itechtics.com” on your web browser, your computer goes to find the corresponding IP address in the hosts file. If the entry is not found there, it then goes to the Domain Name Server (DNS) associated with your computer. This file can be edited for each computer for multiple benefits. Users can use this file to block specific websites, or developers could modify the hosts file to test-run their websites locally on their machine. Let us show you how you can modify the hosts file on your computer and any other computer on your network remotely.

Why you might need to modify the hosts file

When a user opens up a web browser and searches for something or enters a website URL, the computer needs to contact the corresponding IP address to be able to communicate with the website. However, since the computer’s networking system’s primary point of contact is the local hosts file, settings a different IP address for the domain name can trick the computer to transfer to a different IP. This technique is often used by individuals to block certain websites on computers. However, it is not the most optimized way to do so, as the users can change or remove the entry in the hosts file to revert their networking settings. Another reason one might need to consider manipulating the hosts file is to run their own website deployed on the computer and then test it out. Other devices on the same network could then use the local IP address corresponding to the domain name to test their website without going over the internet.

How to edit hosts file on a local computer

The hosts file is a basic system file that can be edited with the built-in Notepad in Windows and is present in plain text. However, to edit it, one needs administrative privileges. A standard user or user account with privileges any lower than an administrator would not be able to edit the file and will be given the following error when trying to save any changes made to it. Let us show you how you can modify the hosts file successfully, without any errors, that is located at the following location: The following method is true for user accounts having Administrative privileges, as well as for the standard users. You can now check that the URL you have entered in the hosts file will now redirect to the corresponding IP. Since we entered 0.0.0.0 in our example, the website www.itechtics.com is no longer accessible.

How to edit hosts file using the Command-line

Alternatively, you can also use the Command Prompt to edit the hosts file in a few easy steps. However, the Command Prompt must be opened as an administrator. This will instantaneously add the IP address and the corresponding domain name to the hosts file. However, if you want to delete it, you will need to use the conventional way by opening up the hosts file in the Notepad and removing the entries manually.

How to edit hosts file on a remote computer

Manually modifying the hosts file on a large number of PCs can be hectic. You can use the following method to remotely edit the hosts file on another computer and make the necessary changes for such a scenario. This part involves some additional steps. However, it is still beneficial and better than going to each computer physically and altering the hosts file. Nonetheless, you will need to perform a small task on the remote computer(s) that will need to be done through physical presence. The following is valid for computers that are on the same network/domain as the source computer. On the remote computer, enter the following command in Run and then reboot the computer: This will add a new DWORD to the Windows Registry that will allow you to access the computer remotely through PsExec. PsExec is a utility created to allow remote access to other computers. This enables users to perform tasks remotely on distant computers without being physically present on-site. When the DWORD has been added to the computer(s) you want to modify the hosts file on, perform the following tasks on the source computer (from where you will be working). You may now press the shortcut keys Ctrl + C to log out of the remote computer’s Command Prompt and proceed to connect to the next PC.

Closing words

Although the hosts file is of significance to the Windows system, it does not affect it in any way if you decide to delete the file voluntarily or involuntarily. Unless you have made certain changes to the file, nothing drastic happens if you remove the entire file. It can always be replaced with a blank file with the name “hosts”. Moreover, any changes made to the file can also be reverted whenever you’d like. Hence, playing around with the file cannot be deemed dangerous for the system. However, it would be wise to create a backup of the original file just in case. Also see:

How To Install Windows 11 Without Microsoft Account (Home And Pro Editions)How To Transfer Files Using Remote Desktop In WindowsHow to Add Programs to Startup in Windows 11/104 Ways to enable Windows Remote Desktop (+ Remotely Enable RDC)How to Delete Locked Files/Folders in Windows 11/10