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 (eg: example.com, test.example.com) and the IP address of the target server. Make sure you close all open browser windows before doing this.
- ‘hosts’ is the name of the file and not another directory name.It does not have an extension (eg: .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 the 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 95/98/Me: C:windowshosts
Windows NT/2000: C:winntsystem32driversetchosts
Windows XP (or higher): C:windowssystem32driversetchosts (you may need administrator access for Windows NT / 2000 / XP / Vista / 7 / 8 / 8.1 / 10)
- Open Windows Notepad (Start -> All Programs -> Accessories -> Notepad)
- Click on the File menu and choose Open…
- Paste that location into the File name: field and click the Open button
- Start on a new line at the bottom of the file. Type the IP address, hit the TAB key, then type the domain*
- 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:
- Browse to Start -> All Programs -> Accessories
- Right click “Notepad” and select “Run as administrator”
- Click “Continue” on the UAC prompt
- Click File -> Open
- Browse to “C:WindowsSystem32Driversetc”
- Change the file filter drop down box from “Text Documents (*.txt)” to “All Files (*.*)”
- Select “hosts” and click “Open”
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).
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.