You know that DNS resolves domain names like TipsMake to IP addresses, such as 104.24.11.25, but did you know there's a file on a Windows 10 computer that can be overridden? It's called the hosts file and allows users to map specific domain names to a chosen IP address . The hosts file only affects the computer, so you can use it to create custom URLs for IP addresses on your network or redirect certain websites.
As you can imagine, editing the hosts file can prevent you from accessing the internet if the file isn't modified correctly. This article will guide you on how to edit the hosts file in Windows 10.
Note: You need to log in with an Administrator account or have administrator privileges to edit the hosts file.
Edit the hosts file by copying it.
Open the folder containing the hosts file using the following path. If Windows is installed on a different drive, please correct the path accordingly.
C:WindowsSystem32Driversetchosts
Copy the hosts file to another folder or your desktop, then edit it:
Copy the hosts file back to the original directory and you're done. Click Continue when prompted for administrator privileges.
Edit the Windows 10 hosts file with administrator privileges.
The hosts file is typically stored in a plain text file in the Windows System folder and can be modified for various use cases. For example, editing the hosts file to block certain websites when creating a computer image for a school. This is perhaps one of the best and easiest ways to ensure students don't access any unauthorized websites like Facebook or YouTube .
In Windows XP and earlier versions, this process was quite easy: just add an exception to the antivirus program , open it in Notepad, make the changes, and then save it.
- A compilation of useful keyboard shortcuts when using Notepad.
On Windows 10, if you edit the hosts file using Notepad as usual, you will encounter the error "You don't have permission to save in this location. Contact the administrator to obtain permission" when saving.
Here's how you can edit the hosts file without getting that error message.
Step 1: Open Notepad with administrator privileges: Type "notepad" into the search bar, right-click on Notepad and select "Run as administrator".
Step 2: In Notepad, click File , then Open. In the File name field , paste the following path into C:WindowsSystem32Driversetchosts:
Alternatively, you can select "All Files" in the file type, and you'll see the hosts file at the top:
Step 3: Now you can edit and save the changes to the hosts file.
To map a domain, simply add a line based on the examples in the hosts file. Start with the IP address, then a space, then the domain name. If you want to block a website , redirect it to 127.0.0.1 .
Remember to remove the '#' before the URL if you want the changes to take effect. Also, remember that www.youtube.com is different from youtube.com, so to be sure, you should add both websites to your hosts file. You need to restart your computer for the hosts file to take effect.
An easier way to edit the hosts file in Windows 10.
If you find the above process a bit cumbersome, there is a third-party utility you can use to modify the hosts file, such as Hosts File Editor by Scott Lerch.
Here's how to edit the hosts file using Hosts File Editor. Download the 1MB installer to your computer and install it. Remember to select the option that only allows you access if you don't want other users to have access to it.
Launch the app from Start > All apps ; this will add the app to your Notification area so you can launch the editor whenever you need it.
Hosts File Editor has a clean, user-friendly interface. To start using the program, fill in the IP Addresses , Host Names , and Comments fields for the websites you want to manage. It's not limited to popular internet websites; even devices on your home network with IP addresses can be managed, so Xbox, iPad, webcam, or router can easily block access if needed.
When you're ready to block a website, select the boxes for the websites you want to block, click Save , and save it.
Another user-friendly feature is the ability to simply right-click on the Hosts File Editor in the Notification area, then click on Disable Hosts File or perform quick edits, without having to search for or launch the command line anymore.
There are some great features for skilled users and network administrators, such as:
- Cut, copy, paste, duplicate, enable, disable, and move one or more items at a time.
- Filter and sort when there are multiple hosts entries.
- Save and restore different hosts file configurations when switching between environments.
- Automatically ping the terminal to check availability.
What happens if the hosts file cannot be saved?
In some versions of Windows, you don't have permission to save directly to the etc. folder. If that's the case, you might encounter an error like the following when trying to save a file:
- Access to C:WindowsSystem32driversetc hosts was denied. ( Access to C:WindowsSystem32driversetc hosts )
- Cannot create the C:WindowsSystem32driversetchosts file. Make sure that the path and file name are correct .
Instead, you must save the file elsewhere, such as in the Documents or Desktop folder. After saving, navigate to that folder, copy the hosts file, and paste it directly into the location containing the hosts file (C:WindowsSystem32driversetc). You will be prompted for permission verification and will have to confirm overwriting the old file.
Note : If you are still having trouble saving the modified hosts file, check the file's properties to see if it is marked as read-only. Right-click the file and select Properties to view the properties.
Another option is to open your text editor with administrator privileges, so that the permissions are applied to that editor. Next, saving the hosts file on the original can be done without needing to verify your administrator login credentials.
If you still can't save to the hosts file location, you may not have permission to edit the files in that folder. You need to log in with an account that has administrator privileges for the hosts file; you can check this by right-clicking the file and going to the Security tab.