Overview
A hosts file is a text file on your home computer. It is used to map a domain name to a specific server. If you edit it, you can change where your computer searches for a website.
For example, when you look up a URL in your browser, your computer sends out a query into the Internet to find where your site is located. Your site is located where your DNS is pointed to. If you edit the hosts file, you can change where your computer searches for a website.
In this way you can view a site on your DreamHost server when the DNS is pointed to another company.
This article explains how to view your site before pointing your DNS to DreamHost by editing the hosts file on your desktop or laptop computer (not a mobile device).
To test on a mobile device, or for another option on how to view your site at DreamHost before pointing DNS, view the following article:
Locate your A records
Each site at DreamHost has two A records for the URL. One for your domain with and without www. For example:
- 208.113.137.245 example.com
- 208.113.137.245 www.example.com
View the DNS article for details on how to view these records. Make a note of these as you'll need to add the IP to your hosts file in the next step.
Using Windows 10
On most Windows systems, you can find the hosts file in the following directory:
C:\Windows\System32\Drivers\etc
Notepad is a basic text editing program that is already install on Windows. To open the hosts file with Notepad, follow the steps below:
- Open the 'Start' menu.
- Start to type in the word 'notepad' and it will display the icon.
- Right-click on the 'Notepad' option and choose 'Run as administrator'.
- You may receive a pop-up message titled “User Access Control” asking, “Do you want to allow this app to make changes to your PC?” Click Yes. This opens a blank Notepad file.
- On the top left of this blank file, click the 'File > Open...' menu option.
- In the 'Explorer' window, navigate to 'This PC'. Then to the C:\Windows\System32\drivers\etc directory.
- Choose the hosts file and click Open. You may need to change the “Text Documents (*.txt)” in the lower right to All Files in the dropdown list.
- At the bottom of the file, add your DreamHost site IP followed by the domain.
208.113.137.245 example.com
208.113.137.245 www.example.com - Save the file.
- Make sure to flush your computer's DNS to ensure the new settings update.
- Restart your browser and try accessing your domain.
You can now view your site as it appears on your DreamHost server. Once you point your DNS to DreamHost, you can then remove these lines.
Using Apple Mac OS
- Launch Terminal by pressing command (⌘) + spacebar which opens the search box.
- Type the word Terminal.
- Press the return key or click the Terminal icon beneath TOP HIT.
- View the Creating and editing a file via SSH article for instructions on how to edit this file. This example uses the nano editor.
[server]$ sudo nano /private/etc/hosts
- Enter the administrator password. Note: Typed passwords are not displayed on the command line.
- Once the hosts file is open, use the arrow keys to navigate to the bottom to make any modifications.
- When finished, save and close the file to return to your terminal prompt.
- Close Terminal when finished.
Make sure to flush your DNS to ensure the new settings update. Once you point your DNS to DreamHost, you can then remove these lines.
Using Linux
On most Linux-based systems:
- The hosts file can be located in the /etc/ directory.
- The hosts file is usually called hosts.
- The full path is /etc/hosts.
The steps to edit and save the file are the same as the 'Mac OS' instructions above.
Move WordPress instructions
This section explains how to view your WordPress site (at DreamHost) if it was moved by the Professional Services Team. This section only applies to NON-DreamPress migrations.
First, read through the sections above to locate and edit your computer's hosts file.
Normally, updating a hosts file only requires you to add two lines (as mentioned above). With this migration process, you also need to add a third line of text for the MySQL server. For example, if your site was example.com, you would add these lines to the bottom of your hosts file:
111.111.111.111 example.com 111.111.111.111 www.example.com 222.222.222.222 mysql.example.com
Replace the example IP addresses above with your site's actual IP addresses.
You can use the following instructions to find your IP addresses on the DNS records Page:
- Navigate to the Manage Websites page.
- Open the DNS Settings page:
- If in Grid view, click the 'vertical 3 dots' button for your domain. From the popout menu, click the DNS Settings link.
- If in List view, either click the DNS link or click the 'vertical 3 dots' button to the right of your domain. From the popout menu, click the DNS Settings link.
- The domain's DNS records display.
If you need further assistance locating your site's IP addresses, view the DNS article for more detailed instructions.
Confirming the 'hosts' file is working
You can confirm you are loading the migrated site from DreamHost's servers if you are able to load the following page (replacing example.com with your domain):
- http://example.com/quickstart.html
View your public site through a proxy
Once your hosts file is working, your computer will show you how your site looks at DreamHost. If you want to also view your current (public) site, you must use a proxy website.
An example of a proxy site is kproxy.com. Visit that link in your browser, enter your domain name in the box, then press Enter. It uses your site's public DNS (not your local hosts file) to view the site at your current hosting company.
Comparing the sites
Viewing your site using a hosts file and a proxy site allows you to view both versions of your site for a side by side comparison. You can have one browser tab open on the migrated site (viewed using your hosts file) and another browser tab open on the proxy site (viewed using DNS) to see your current public site.
Making further changes to your site
During your inspection of the site, you may feel the need to change the setting of something that was out of scope of the migration service. Please refrain from changing anything that may alter the look or behavior of the site since the Professional Services Team must be able to compare the migrated site (at DreamHost) to the live site (at your current host).
If you must update something, make sure to document any change so the Professional Services Team can separate what may have been affected by the migration from subsequent alterations on your end.