Site: US UK AU |

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. 

Before proceeding

You must know the IP address associated with your domain. To identify it, either refer to your Welcome Email 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.

Stage 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 (Figure 1).
  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 hosts file. Navigate to the end of the file, and then type the following information all on the same line:

  11. Under File menu, click Save.
  12. Open the Windows command prompt.  
  13. 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.
  14. Flush the DNS cache by typing the following command with a space between ipconfig and /flushdns:  

    ipconfig /flushdns

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

    Example Windows Command Prompt Showing Successful DNS Cache Flush

  16. To test your website's navigation and functionality, open your browser, enter your website's address, and explore your site. 
  17. 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
  5. Save the hosts file by pressing Ctrl-O.
  6. When "File Name to Write" prompt appears, press Return.
  7. 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

  8. Exit the Terminal completely by pressing Cmd-Q.
  9. To test your website, open your browser and type the web address for your domain name.
  10. Proceed to the Stage 2: Disable the mapping when you are ready for your site to be live.

Stage 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 procedure:

  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 (15 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
Nexcess Acceptable Use Policy
Added on Thu, Jul 25, 2013
How to edit php.ini
Added on Mon, Nov 10, 2014
How to create and edit reverse DNS records in the Client Portal
Added on Mon, May 7, 2018
Overview of DNS records
Added on Fri, Dec 12, 2014
How to configure DNS records in SiteWorx
Added on Tue, Jul 31, 2018
How to Install dotProject
Added on Thu, Mar 20, 2014
How to install Invision Power Board
Added on Thu, Mar 20, 2014
Installing Revive Adserver on your site
Added on Mon, Dec 30, 2013
How to install Vanilla Forums Community Edition 1.8
Added on Wed, Mar 19, 2014