How to edit your hosts file

Share on facebook
Share on twitter
Share on pinterest
Modifying your host file is extremely useful when previewing or migrating websites. For instance, when you need to preview your website on your hosting account, before you publish the changes, the best practice is to edit your host file. This will direct your computer, and only your computer, to the exact location you specify. Migrating a site, but don't want to make it live until you know it works? Edit your Host file...

How to Preview your Website by editing your Hosts file

Editing your hosts file enables you to override the domain name system (DNS) for a domain on a specific server. This process is useful in the following situations:

Raspberry Pi 4 now has Dual Display capabilities, each with 4k display.

A company migrates your site, and asks you to take a look at their work before making the site live.   

Your site is still live on the original server, so how do you view it on the new one?

Companies like GoDaddy migrates sites in this manner.  Now comes the part where you need to check the migrated site, before changing where your domain points.  Luckily, there is an easy way to do just that.

Editing your hosts file causes your local machine to skip the DNS process entirely, and look directly at the Internet Protocol (IP) address that you specify.

Modifying the hosts file involves adding two entries to it. Each entry contains the IP address to which you want the site to go to and a the internet address.  

For example, add the following two entries to your hosts file, directly after the IP address: www.domain.com and domain.com.  Change out ‘domain’ with the real name of your site.

For instance, you might see the below entry, in our hosts file.

64.49.219.194 www.digitallythrive.com

64.49.219.194 digitallythrive.com

So how do I edit my hosts file?

This article provides instructions for locating and editing the hosts file on the following operating systems

  • Microsoft® Windows® 10, Windows 8, Windows 7, and Windows Vista™
  • Microsoft Windows NT™, Windows 2000, and Windows XP

Edit your hosts file in Windows

If you are using a Microsoft operating system like Windows 10, Windows 8, Windows 7, and Windows Vista you must run Microsoft Notepad as an administrator.

To edit your hosts file on windows, make sure you run Notepad as Administrator, by right clicking on it first, and choosing Run as Administrator.

Windows 10 and Windows 8

Watch for steps marked with  *IMPORTANT  – which are flagged as the most common mistakes made.  DigitallyThrive found several areas that were either incorrectly documented, or extremely vague.  These steps, if incorrectly done, will cause the entire process to fail.  Due to the confusion, along with the current shoddy documentation of this on the internet, we have included screenshots for all of you.  

Find the hosts file in Windows, System 32, drivers, etc. Make sure you change Textfiles Only (*.txt) to All Files in the dropdown box on the right.
How to save your hosts file on Windows 10: Click Save as, Click file type and set to All Files