How to preview a website before DNS update is complete

How to preview a website before DNS update is complete

Overview
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. 

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.

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.

  • 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.

Step 1: Edit the host file and test your website

Follow the 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. Confirm when prompted. If the confirmation request also prompts you to enter a password, 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, add a new mapping to the hosts file. Navigate to the end of the file, and then type the following information on the same line. Include a space between each.
    • The server IP address provided by Nexcess Support. If you do not have the IP address, contact the Nexcess Support Team
    • Your domain name.
    • Your domain name, preceded with www.
       Example Hosts File Edited in Notepad

  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. 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, 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 on the same line. Include a space between each.
    • 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, domain.com.
    • Your domain name, preceded with www; for example, "www.domain.com"
       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. Proceed to the Step 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
Nexcess Acceptable Use Policy
Added on Thu, Jul 25, 2013
How to enable SPF records
Added on Tue, Jul 30, 2013
How to change PHP versions in SiteWorx
Added on Mon, Aug 13, 2018
What is the PHP-FPM limit (max_children)?
Added on Fri, Jan 25, 2019
How to use TraceRoute
Added on Fri, Feb 15, 2019
How to verify DNS propagation
Added on Tue, Jul 30, 2013
How to create and edit reverse DNS records in the Client Portal
Added on Mon, May 7, 2018
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
How to install PrestaShop
Added on Mon, Feb 25, 2019