View your DreamHost site using a hosts file

 

Overview

This article explains how to view your website before pointing your DNS to DreamHost by editing the hosts file on your computer.

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:

What is a hosts file?

A hosts file is a text file used by your computer that changes where your computer searches for a specific website. For example:

  • when you visit a website, your computer follows the public DNS records of the internet.
  • when you edit the hosts file, you control the DNS records your computer uses.

This allows you to view a site on your DreamHost server when the public DNS records are pointed to another company.

A records

The hosts file uses A records (IP addresses) to locate your site at DreamHost. Each site at DreamHost has two A records for the URL: one for your domain with and one without www. For example:

  • 111.222.333.444 example.com
  • 111.222.333.444 www.example.com

View the following article to locate these two records for your website:

Updating your hosts file

The following sections describe how to locate and update your hosts file on different operating systems.

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 installed on Windows. To open the hosts file with Notepad, follow the steps below:

  1. Open the Start menu.
  2. Start typing the word 'notepad', and it will display the icon.
  3. 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.

  4. Click the File > Open... menu option in the top left of this blank file.
  5. Navigate to This PC in the Explorer window and then to the C:\Windows\System32\drivers\etc directory.
    02 Hosts file Windows.png
  6. 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.
  7. Add your DreamHost site IPs followed by the domain at the bottom of the file.
    xxx.xxx.xxx.xxx example.com 
    xxx.xxx.xxx.xxx www.example.com
  8. Save the file.
  9. Flush your computer's DNS to ensure the new settings update.
  10. Restart your browser and visit 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.

Mac OS

  1. Launch Terminal by pressing command (⌘) + spacebar which opens the search box.
  2. Type the word Terminal.
  3. Press the return key or click the Terminal icon beneath TOP HIT.
  4. View the Creating and editing a file via SSH article for instructions on how to edit this file. This example uses the nano editor.
  5. Type the following into your terminal:
    [server]$ sudo nano /private/etc/hosts
  6. Enter the administrator password.
    08 DNS hosts.fw.png
  7. Use the arrow keys to navigate to the bottom once the hosts file is open to make any modifications.
  8. Save and close the file when finished to return to your terminal prompt.
  9. Close the Terminal when finished.
  10. Flush your DNS to ensure the new settings update.

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.

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.

WordPress Professional Services migrations

This section explains how to view your WordPress site (at DreamHost) if it was migrated by the Professional Services Team. This section only applies to NON-DreamPress migrations.

Locate and edit your computer's hosts file as described above. With this migration process, you must add a third line of text for the MySQL server. For example, if your site were 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

Making further changes to your site

Please refrain from changing anything that may alter the site's look or behavior since the Professional Services Team must be able to compare the migrated site (at DreamHost) to the live site (at your current host).

Viewing your site

This section explains how to compare your DreamHost site to your live website.

Confirming the 'hosts' file is working

You can confirm you are loading the migrated site from DreamHost's servers if you can 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 works, 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. The proxy site will use your site's public DNS (not your local hosts file) to view the site at your current hosting company. 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. 

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?