Share this article
Improve this guide
How to Edit the Hosts File in Windows 10
Learn how to change the DNS settings on your device
4 min. read
Updated onApril 11, 2024
updated onApril 11, 2024
Share this article
Improve this guide
Read our disclosure page to find out how can you help Windows Report sustain the editorial teamRead more
Key notes
The computer’s hosts file is a Windows file that translates hostnames toIP 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 modify 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 host file in Windows 10?
1. Edit the hosts file using Notepad
- Click on theStartbutton on the taskbar or press the Windows key on your keyboard.
2.Typenotepadin the search box that opened.
-
Right-click on the first result and selectRun as administrator.
-
When the Notepad app opens, selectFile, from the menu, and thenOpen.
5.You will find thehosts.txtin the following location (You need to selectAll filesfrom the drop-down menu, in order to see the hosts.txt file):C:\Windows\System32\Drivers\etc
- Select the file and hitOpen.
7.Make the desired changes in the hosts file. Write just one entry per line.
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).
-
After you finish, click again onFileandSave.
-
Close Notepad.
If you need to make changes to the hosts file on your Windows OS, you can easily do this through the built-in Notepad tool.
After opening the hosts file in Notepad, you can modify it to override the current DNS settings and set-up new ones.
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
If you change your mind, just open the hosts file again and edit or delete the lines. We also have a guide onhow to reset the hosts file back to default in Windows 10.
3. Create a shortcut for the hosts file
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.
Are there differences when you 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,Notepadis already pinned to theStartmenu.
One more thing that you have to know about host 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 likeESET HOME Security Essentialwhich 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.
More about the topics:Windows 10 Guides,Windows 11
Madalina Dinita
Networking & Security Specialist
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 – AI and DNA computing in particular.
Prior to joining the WindowsReport team, she worked in the corporate world for a number of years.
User forum
0 messages
Sort by:LatestOldestMost Votes
Comment*
Name*
Email*
Commenting as.Not you?
Save information for future comments
Comment
Δ
Madalina Dinita
Networking & Security Specialist
Madalina is a Windows fan since forever, especially interested in AI, emerging technologies, privacy, and security.