How to preview a website before DNS update is complete

How to preview a website before DNS update is complete

This article shows how you can preview and test your website after migration without waiting for DNS propagation, which can take several days. 

If you have just registered a new domain name with Nexcess, or have transferred your existing domain to Nexcess, it can take up to 7 days for your domain information to fully propagate across the Internet. During this time, your website will be invisible on the Web. Rather than wait for the propagation to complete, you can preview and test your website from our servers as though it were live by adding a line of text to your computer's hosts file.

The hosts file is a plain text file found on most computers running operating systems such as Linux, OSX, and Windows. There are a variety of uses for the hosts file; however, one of the more common uses is to map domain names to specific IP addresses. 

But first...

You must know the IP address associated with your domain. To identify it, see How to find the IP address of a website or server, or contact our Support Team.

In general, if your hosts file contains domain-to-IP mappings, your system will follow those mappings rather than request information for your domain from the DNS servers. Therefore, if you are editing your hosts file for temporary purposes, keep in mind that you will need to disable the mapping when it is no longer needed. You can do this by either entering a "#" at the beginning of the line of the mapping, or by deleting the mapping altogether. For details, refer to the Disable the Mapping section below.

Editing your hosts file affects only the computer storing the file; it has no bearing on other computers. In other words, if your domain is not yet fully transferred, it will remain unavailable for viewing across the Internet. This workaround is intended specifically for the website owner who needs to test and develop their website from the Web server while their domain is going through the propagation process.

Step 1: Edit the host file and test your website

Follow the appropriate procedure for your operating system:

For Windows

    1. Locate the Notepad program using the method corresponding to your version of Windows: 
      • For Windows 7 and earlier, click Start >Accessories.
      • For Windows 8 or 10, type Notepad into the Start menu.

    2. When the Notepad option appears, right-click on it and select Run as administrator.

    3. An UAC pop-up message appears, prompting you to confirm allowing the Notepad program to make changes. If the message box also prompts you to enter a password for administrator credentials, enter the password and then click Continue or OK. If you do not know the password, contact your system administrator or refer to Windows Help for information on how to obtain a full administrator access token.

    4. Depending on your version of Windows, click Yes or Continue.

    5. In Notepad, click File > Open and browse to C:\Windows\System32\drivers\etc

    6. Select the \etc folder.

    7. In order to see the hosts file,  change the file type from *.txt to *.*

    8. As shown below, click the File Type drop-down list located to the right of the File name field and select All Files (*.*). The hosts file should appear in the directory list.
      Example Windows Open Dialog Box Showing

    9. Double-click the hosts file and it will open in Notepad for editing.  
      Example Hosts File Open in Notepad
    10. Next, you will add a new mapping to the 
     file. Navigate to the end of the file, and then type the following information all on the same line:
    • The server IP address provided by Nexcess Support. If you do not have the IP address, contact the Nexcess Support Team. Enter at least one space between the IP address and the domain name.
    • Your domain name.
    • Your domain name, preceded with www.
       Example Hosts File Edited in Notepad

  1. Under File menu, click Save.

  2. Open the Windows command prompt.  

  3. Choose the method corresponding to your version of Windows:
    • In Windows 7 or earlier, Click Start, type command, and select Command Prompt in the search results listing.
    • In Windows 8 or 10, type X and the Windowskey at the same time, then select Command Prompt.

  4. Flush the DNS cache by typing the following command with a space between ipconfig and /flushdns:  

    ipconfig /flushdns

  5. Click Enter. The following message should display: "Successfully flushed the DNS Resolver Cache."

    Example Windows Command Prompt Showing Successful DNS Cache Flush

  6. To test your website's navigation and functionality, open your browser, enter your website's address, and explore your site. 

  7. Proceed to the Stage 2: Disable the mapping when you are ready for your site to be live.

For OS X

    1. Open the Terminal application by either typing Terminal on the Spotlight, or selecting  Applications > Utilities > Terminal.

    2. In the Terminal window, open the hosts file by typing the following command string: 

      sudo nano /private/etc/hosts

    3. When prompted, type your user password. The hosts file contains some comments preceded with #, as well as some default hostname mappings.
      Example Hosts File displayed in nano
    4. Next, you will add a new mapping to the hosts file. Using your arrow keys, navigate to the end of the file, and then type the following information, all on the same line:
  • The server IP address provided by the Nexcess Support Team. if you do not have the IP address, contact them
  • Your domain name; for example,
  • Your domain name, preceded with www; for example, ""
     Example Hosting File Showing Example IP/Domain Info
  1. Save the hosts file by pressing Ctrl-O.

  2. When "File Name to Write" prompt appears, press Return.

  3. Exit by pressing Ctrl-X. Now that you have exited the editor, you should see the Terminal prompt again. For changes to take effect, you must flush your DNS cache. Since different versions of OS X use different commands, run the following and ignore any command not found output:

    sudo discoveryutil udnsflushcaches ; sudo dscacheutil -flushcache ; sudo killall -HUP mDNSResponder

  4. Exit the Terminal completely by pressing Cmd-Q.

  5. To test your website, open your browser and type the web address for your domain name.

  6. Proceed to the Stage 2: Disable the mapping when you are ready for your site to be live.

Step 2: Disable the mapping

When you are ready for your website to be visible across the Internet and the domain is properly pointing to Nexcess nameservers, you must disable the temporary mapping that you added to the hosts file. To do so, use the following method:

  1. Under the section corresponding to your computer's operating system , follow the steps for opening the hosts file.

  2. Navigate to the line of text that you added, and either type # at the beginning of the line, or delete the line. Take care to delete only the text line for your mapping.
  3. Save the hosts file. 


For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to verify DNS propagation
Added on Tue, Jul 30, 2013
How to find the IP address of a website or server
Added on Fri, Feb 15, 2019
How to install dotProject
Added on Mon, Feb 25, 2019
What is a Nexcess site-to-site VPN Tunnel?
Added on Mon, Feb 11, 2019
How to change PHP versions in SiteWorx
Added on Mon, Aug 13, 2018
How to install phpBB
Added on Mon, Feb 25, 2019
How to enable SPF records
Added on Tue, Jul 30, 2013
How to generate DNS records
Added on Wed, Aug 14, 2013
How to edit php.ini
Added on Mon, Feb 11, 2019
Overview of DNS records
Added on Fri, Dec 12, 2014