A hosts file is a text file that stores information that is used to map servers or hostnames to IP addresses. Even though DNS is primarily used for IP resolution now, Windows still stores the hosts file.
Occasionally, you might need to edit this hosts file. Editing the host file allows you to trick your computer into resolving to a specific IP Address that you want. There could be many reasons for you wanting to edit the hosts file. Maybe you’re working with domain-name-independent software. Or you’re leaving an old server and want to test your domain before moving the DNS settings. Whatever the reason, it is fairly simple to edit the hosts file in Windows 11.
First, Backup the Hosts File
Before editing your hosts file, you should create a backup of the hosts file. In case something goes wrong, you should be able to restore it to a version that worked.
Launch File Explorer on your PC and then go to the
etc folder. If your Windows is in another drive, you’d have to accordingly change the drive from
C: to the drive where Windows is installed on your computer.
Alternatively, you can also copy and paste the file path below in the File Explorer and hit enter to open the
hosts file folder.
You’d see a file with the name
hosts in this folder. Copy the hosts file and paste it in another location for backup. You could also save it in the
etc folder by another name, but it’ll ask for Administrator permission to do that.
Edit Hosts file using Notepad on Windows 11
First, open the Notepad as an administrator. To do so, search ‘Notepad’ in the Start menu and then right-click on the Notepad app icon and select ‘Run as administrator’ from the menu.
Windows will display a permission prompt asking, “Do you want to allow this app to make changes to your computer?” Click on the ‘Yes’ button. This will open the notepad with admin privileges so you edit the hosts file using it.
Next, in Notepad, go to the ‘File’ menu option and select ‘Open’ from the menu. You can also use the ‘Ctrl + O’ keyboard shortcut.
Then, copy and paste the
hosts file address in the ‘File name’ field in the Open dialog box and press Enter.
You can also manually navigate to and open the hosts file by going to
etc folder in the Open dialog box. But first, you’d have to change the file type from ‘Text files’ to ‘All files’ as the hosts file is not your standard text file.
The hosts file will open in Notepad, and you can edit it easily.
Add the new IP addresses and the domain names that you want to resolve at the end of the file and save it using the Ctrl + S keyboard shortcut. As we opened Notepad in Administrator mode, you’d be able to easily save the file without any further need for permissions.
And that’s it. You have successfully modified your hosts file in Windows 11.
Windows 11 might be a lot different visually than Windows 10. But most of the underlying stuff remains as is, especially the files and folders structure of the Windows system folder. You can easily navigate and use the same tricks you used in Windows 10 to get around in Windows 11 as well.