One of the most powerful tools available to anyone working on their site during a migration is their computer’s “hosts” file. The hosts file is used to map domain names to IP addresses, and can be used as an alternative to DNS. It also allows you to specify the IP address to which a website resolves on your computer, regardless of what may be published in the site’s DNS zone file.
Editing Your Hosts File
To change the host your domain loads from, you need to know the correct IP for your server. Servers will require you to use the IP address displayed in your cPanel.
You can view your Site IP by accessing your cPanel and looking within the General Information section in your right-hand sidebar:
Editing System Files
Lastly, you may change the host your local computer loads your website from by directly editing your system's hosts file. This method will be easier if you are an experienced user of the operating system on your local PC.
All operating systems will have a hosts file like our example:
127.0.0.1 localhost
123.45.67.89 www.example.com
#98.76.54.32 www.another-example.com
Add the second line in this example to your hosts file, with the following edits:
- Replace 123.45.67.89 with the IP address from your cPanel.
- Replace www.example.com with your actual domain name.
You may deactivate a line to undo this change by prefacing it with a # (as in the third line above). This will cause the line to be ignored.
Note: Remember to undo the changes you make after you're done viewing your site, as any of these changes will prevent your domain from loading the correct DNS.
Click the links below to expand specific instructions for how to make this change your desired operating system:
Windows
Windows 8 and Windows 10
- Select the Start key and locate Notepad. (If you do not see it on your current Start page, begin typing Notepad and a search box will appear on the right side of the screen with a list of programs under it. Notepad should be at the top of this list.
- Right-click on Notepad. You will see options appear on the bottom portion of the Start Page.
- Select Run as administrator.
Note: Performing this action may cause Windows User Account Control to prompt you with a warning, or if you are logged in as another user, a request for the Administrator password. This step is necessary to modify system files such as the hosts file.
- Click File in the menu bar at the top of Notepad and select Open.
- Click the drop-down box in the lower right-hand corner that is set to Text Documents (*.txt) and select All Files (*.*)
- Browse to C:\Windows\System32\Drivers\etc and open the hosts file.
- Make the needed changes, as shown above, and close Notepad.
- Save when prompted.
Windows 7 or Vista
- 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:\Windows\System32\Drivers\etc.
- Change the file filter drop-down box from Text Documents (*.txt) to All Files (*.*).
- Select hosts, and click Open.
- Make the needed changes, as shown above, and close Notepad.
- Save when prompted.