How to Safely Edit the Hosts File in Windows (NO Notepad)

I use the Windows Hosts file while migrating servers, and I need to test that my site is working correctly on another IP address before making the changes to the DNS servers. Unfortunately, most tutorials tell you to modify the Hosts file using Notepad, which is dangerous because you can easily make syntax errors and break stuff. But thanks to Microsoft’s PowerToys tool, you can safely edit the Hosts file without opening Notepad and activating or deactivating rules.

Here’s a tutorial on how it works.

1: Download and Install Windows PowerToys

Microsoft’s official PowerToys tool is a fantastic app that I always use, and I particularly love the PowerToys Run tool that I use instead of the Windows start menu button. Amongst the many utilities, it also includes a Hosts file editor that sanitizes the dangerous task of modifying a key text configuration file.

You can install PowerToys in two ways;

  1. Using the Microsoft Store PowerToys app
  2. Download the .exe file from the GitHub page under “Assets”
Download Microsoft PowerToys from GitHub
Download Microsoft PowerToys from GitHub

Install the EXE file, and you’re done.

2: Launch the Hosts File Editor in Windows PowerToys

Launch Windows PowerToys, and on the right-hand side, click the “Hosts File Editor” as shown here:

Hosts File Editor in Windows PowerToys
Hosts File Editor in Windows PowerToys

Not all PowerToys modules are enabled by default, so first, ensure that the “Enable Hosts File Editor” toggle is enabled, and then click “Launch Host File Editor” as shown above.

3: Safely Edit your Hosts File

In the dialog box, you’ll see a list of entries that already exist in the Hosts file, and you can enable or disable them accordingly. If you’re doing this for the first time, then click the “New Entry” button on the top as shown here:

Add a New Entry to the Hosts File Editor Tool
Add a New Entry to the Hosts File Editor Tool

This will create a new form to associate an IP address with a domain name. In this example, I’m using my website name wp-tweaks.com and a random IP address:

Add the IP Address and Hostname to the Hosts File Editor
Add the IP Address and Hostname to the Hosts File Editor

Once you’re done, click the “Add” button, ensure your new Hosts entry is enabled, and you’re done! Once you’re through testing, repeat the above steps and disable the entry you created. No more messing around with Notepad, no worries of accidentally breaking stuff, and no need to navigate through complex folder structures to access the Hosts file.

As a bonus, you can now use the Windows PowerToys tool to spruce up your PC workflow. I highly recommend it!

About Bhagwad Park

I've been writing about web hosting and WordPress tutorials since 2008. I also create tutorials on Linux server administration, and have a ton of experience with web hosting products. Contact me via e-mail!

Speak Your Mind

*

WP-Tweaks