1. Home
  2. Cloud & Dedicated Servers
  3. Domain Name Services (DNS)
  4. How do I edit my hosts file to preview a domain name?

How do I edit my hosts file to preview a domain name?

The instructions below explain how to update the hosts file on your PC. This is useful when trying to preview a domain before updating DNS.  You will need the domain name (e.g.: example.com, test.example.com) and the IP address of the target server. Make sure you close all open browser windows before doing this. 

NOTE:

  • “hosts” is the name of the file and not another directory name.  It does not have an extension (i.e., it’s not a .exe, .txt, .doc, etc.)
  • This ONLY works on the computer where you changed the “hosts” file
  • You can add more than one hostname on the same line, just make sure you have at least one space or TAB in between each one.
    • Example line:

      192.168.0.10 example.com test.example.com www.example.com

  • This is only a temporary fix. Once your registrar has updated your DNS information (and enough time has passed for propagation) you will need to remove any lines you added to the “hosts” file.

Common locations of the ‘hosts’ file:

Windows 10, 8.1, 8, 7, Vista, XP: C:\Windows\System32\drivers\etc\hosts (you may need administrator access for Windows NT / 2000 / XP / Vista / 7 / 8 / 8.1 / 10)
Windows ME / 98 / 95: C:\Windows\hosts
Windows NT / 2000: C:\WINNT\System32\drivers\etc\hosts

  1. Open Windows Notepad (Start -> All Programs -> Accessories -> Notepad)
  2. Click on the File menu and choose Open…
  3. Paste that location into the File name: field and click the Open button
  4. Start on a new line at the bottom of the file.  Type the IP address, hit the TAB key, then type the domain*
  5. Save the file and close all open browsers before attempting to browse to the domain

If you are using Windows Vista/7 you may need to save the hosts file entries using the steps outlined below:

  1. Browse to Start -> All Programs -> Accessories
  2. Right click “Notepad” and select “Run as administrator
  3. Click “Continue” on the UAC prompt
  4. Click File -> Open
  5. Browse to “C:WindowsSystem32Driversetc”
  6. Change the file filter drop down box from “Text Documents (*.txt)” to “All Files (*.*)”
  7. Select “hosts” and click “Open”
For Windows 10, open File Explorer by clicking the Cortana search icon next to the “Start” button, then click File Explorer:

Navigate to the folder directory C:\Windows\System32\drivers\etc\hosts.  You should see the following:

Right-click on the hosts file and click Edit with Notepad++.  (If you don’t have Notepad++, you can download it from https://notepad-plus-plus.org). 

Start on a new line at the bottom of the file.  Type the IP address of your web site, hit the TAB key, and type the your domain name and any subdomains if applicable . 
EXAMPLE:
999.999.99.999    YourDomain.com        www.YourDomain.com        Subdomain2.YourDomain.com

Save the file.   (You may need administrative privileges to save the file).

Content retrieved from: https://support.appliedi.net/kb/a213/how-do-i-edit-my-hosts-file-to-preview-a-domain-name.aspx.

Updated on April 29, 2021

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT