Advertisement

How to Edit the Hosts File in Windows 10

Every Windows version comes with a special Hosts file which helps resolving DNS records. In addition to your network configuration, the file can be used to define a domain=IP address pairing which will have priority above the value provided by the DNS server. Here is how to edit this file in Windows 10.

Advertisеment


The ability to edit the Hosts file is useful in many situations. While doing web development, you can make your computer resolve a domain to a local address. Mapping a network device name to its IP address with the Hosts file will allow accessing the device by its name from File Explorer.

The Hosts file is just a regular text file which can be modified using any text editor. The only catch is that the editor app should be started elevated (as Administrator). The hosts file is located in the system directory, so non-elevated apps will fail to save it.

To edit the Hosts file in Windows 10, do the following.

  1. In the Start menu, go to Windows Accessories.
  2. Right-click the Notepad app and select More - Run as Administrator.Run Notepad Elevated
  3. In Notepad, click the File menu - Open, or press the Ctrl + O keys.
  4. Navigate to the folder C:\Windows\System32\drivers\etc.
  5. Select "All Files" from the drop-down menu.
  6. Double-click the hosts file.Notepad Open Hosts
  7. Type the IP address of the domain followed by the domain name you want to use to resolve the remote destination host. Save the file(Ctrl + S).Windows 10 Edit Hosts File

Use one entry per line. Entries should look as follows:

127.0.0.1 google.com

To test the changes you have made, open a command prompt and use the ping command to see the address in the output.

In my case, the remote address of the google.com domain will be resolved to my local computer.

Windows 10 Test Hosts File

Your hosts file might be modified by anti-malware apps to block dangerous domains or ads. The popular Spybot - Search & Destroy and Spybot Anti-Beacon apps are known to do this.

We also saw how to block ads using the host file when Edge lacked ad blocking addons. People have also modified it to block many Windows 10 telemetry and data collection servers before Microsoft used tricks to workaround this limitation.

Malware can also use the hosts file to hijack genuine domains so besides the usual admin permission-based protection that Windows has for the HOSTS file, you can also set the Read-only attribute for it. When you need to modify it, simply temporarily remove the Read-only attribute, edit it as Administrator and set it again.

That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.