How to Edit the Hosts File in Windows 10
How to Edit the Hosts File in Windows 10
If you’re a regular groovyPost reader, you know that DNS translates domain names like groovyPost.com into IP addresses like 104.24.11.25. But did you know that there’s a file on your Windows 10 PC that can override that? It’s called your hosts file and lets you map specific domain names to an IP address of your choosing. Your hosts file only affects your computer, so you can use it to create custom URLs for IP addresses on your network, or you can use it to redirect certain websites.
As you can imagine, editing the hosts file can easily break your internet if it’s modified incorrectly or maliciously. So, it’s not particularly easy for a normal user to edit. This is a good thing. But if you want to purposefully change your hosts file, here’s how.
Edit Your Windows 10 Host File as an Administrator
The hosts file is normally stored in a plain text file in the Windows System folder and can be modified for a variety of use cases. One particular reason I edited the Host file in the past was to block certain websites when I imaged computers for a local high school. This was probably one of the best and easiest ways I could ensure students didn’t load any unauthorized websites such as Facebook or YouTube.
Editing your Windows Hosts file doesn’t have to feel like going down a rabbit hole. In Windows XP and earlier versions, the process was quite easy, just add an exception to your antivirus, open it in Notepad, make your changes then save it.
In Windows 10, if you try to edit your hosts file, you’ll probably be able to open it just fine, but when you go to save it, you’ll get an error:
Here’s how you can edit your hosts file without getting the “You don’t have permission to save in this location. Contact the administrator to obtain permission” error.
Hit the start menu or press the Windows key and start typing Notepad.
Right-click Notepad and choose Run as administrator.
In Notepad, click File then Open… In the File name field, paste the following path in:
c:\Windows\System32\Drivers\etc\hosts
Now you’ll be able to edit and save changes to your hosts file.
To map a domain, simply add a line based on the examples in the hosts file.
Start with the target IP address, then a space, then the domain name. If you want to block a website, redirect it to 127.0.0.1.
Don’t put in the # if you want it to take effect.
Also, remember that www.youtube.com is different than youtube.com.
You may need to restart your computer for the new hosts file to take effect.
留言
張貼留言