How to edit Windows 10 & 11 hosts file [Step-by-step guide]

by Madalina Dinita
Madalina Dinita
Madalina Dinita
Windows & Software Expert
Madalina has been a Windows fan ever since she got her hands on her first Windows XP computer. She is interested in all things technology, especially emerging technologies... read more
Affiliate Disclosure
  • The hosts file from Windows converts the hostnames into numeric protocol addresses (IP address).
  • That is why editing the hosts file will help you override the DNS settings for a domain or a PC.
  • It's very easy to do so by using Notepad but we also explain how to pin the shortcut for quick access.
Windows 10 and 11 hosts file editing
XINSTALL BY CLICKING THE DOWNLOAD FILE
To fix various PC problems, we recommend DriverFix:
This software will keep your drivers up and running, thus keeping you safe from common computer errors and hardware failure. Check all your drivers now in 3 easy steps:

  1. Download DriverFix (verified download file).
  2. Click Start Scan to find all problematic drivers.
  3. Click Update Drivers to get new versions and avoid system malfunctionings.
  • DriverFix has been downloaded by 0 readers this month.

The computer’s hosts file is a Windows file that translates hostnames to IP addresses.

Precisely, it serves the function of converting the hostnames into numeric protocol addresses (IP address), that will locate a host in an IP network. The hosts file has the form of a plain text file.

Before the development of domain name systems (DNS), hosts files were the only solution for the computers to map hostnames to IP addresses.

After this process was automated through a DNS, the purpose of hosts file became a bit useless.

Most users of computers do not know that a file called hosts.txt exists. Still, in modern operating systems, his function can be handy.

The hosts file remains an alternative name interpretation mechanism and takes priority over the configured DNS server.

Why would you need to edit the hosts file?

Usually, editing the hosts file is performed to override the DNS settings for a domain or a computer.

For example, when you want to block the access to a specific website, from your computer. Or when you transfer a website to a new host provider.

First, you need to move the files to the new server and then shift the domain to a new IP address.

Or maybe, when you do not have a configured DNS server and you need to translate an IP address to a computer name. It’s just easier to use a hostname, than a sequence of numbers (IP address).

Whatever the reason you may have, in this article, we will list the steps to edit the hosts file on Windows 10.

How can I edit the Windows 10 & 11 hosts file in Notepad?

1. Edit the hosts file using Notepad

  1. Click on the Start button, type notepad, right-click on the app and select Run as administrator.
  2. Select File, from the menu and then Open.
  3. You will find the hosts.txt in the following location (You need to select All files from the drop-down menu, in order to see the hosts.txt file): C:\Windows\System32\Drivers\etc
  4. Then select the file and hit Open.
  5. Make the necessary changes in the hosts file. Write just one entry per line, just like in our example.
  6. After you finish, click again on File and Save.
  7. Close the notepad.

For example, type the IP address, space (or tab), and then the domain or computer name that you want to use to get to the device/application/website.

After these, you can add also a comment (with a # hashtag sign in front).

Expert Tip: Some PC issues are hard to tackle, especially when it comes to corrupted repositories or missing Windows files. If you are having troubles fixing an error, your system may be partially broken. We recommend installing Restoro, a tool that will scan your machine and identify what the fault is.
Click here to download and start repairing.

To block your computer’s access to a specific website, you can use an invalid IP address (e.g. 10.10.10.00 or localhost: 127.0.0.1) followed by the domain name (e.g. windowsreport.com) and the comment (e.g. #block site)

2. Test the hosts file using Command Prompt

  1. Click the Start button type cmd and select Run as administrator.
  2. In that window, ping the website that you have blocked. To do that, type the following command: ping www.windowsreport.com

If you change your mind, just open the hosts file again and edit or delete the lines. We also have a guide on how to reset the hosts file back to default in Windows 10.

3. Create a shortcut for the hosts file

  1. Click the Start menu, search notepad, right-click on it and choose Pin to Start.
  2. Once you have the shortcut on the Start menu, you have to right-click on it and choose More, then Open file location.
  3. Right-click on the shortcut and Properties.
  4. In the Target box, it will be filled with the default Notepad path. Replace it with this path: C:\Windows\system32\drivers\etc\hosts
  5. Then, click Apply and OK to make the changes.

If you are a programmer that works on websites, you probably need to edit the hosts file again and again.

To make things simpler, you can make a shortcut in the Start Menu, which will open the hosts file into Notepad, with administrator rights.

How to edit the hosts file in Windows 11?

Although it comes with a lot of new features and design, Windows 11 is not that different from Windows 10.

That means, in part, that all the solutions to edit the hosts file we’ve presented above can be applied seamlessly for the new OS as well.

In fact, it will be a little more simple because, as you will probably notice, Notepad is already pinned to the Start menu.

One more thing that you have to know about hosts file is that this file can be infected with malware.

Through hosts file, viruses corrupt your system and redirect it to other malware-ridden websites.

So, if you are trying to cleanse your computer, it’s always a good idea to check the hosts.txt file.

You can always clear things out by using a third-party antivirus like ESET Internet Security which is very reliable and will do the job perfectly.

That’s it! Now you know how you can edit the hosts file in Windows 10 and 11 and override the DNS settings for a domain or a computer.

If you have any suggestions or if our guide helped you, the comments section below is ready for your input.

idee restoro Still having issues? Fix them with this tool:
  1. Download this PC Repair Tool rated Great on TrustPilot.com (download starts on this page).
  2. Click Start Scan to find Windows issues that could be causing PC problems.
  3. Click Repair All to fix issues with Patented Technologies (Exclusive Discount for our readers).

Restoro has been downloaded by 0 readers this month.

This article covers:Topics: