For Service Outages & Network Status Alerts Visit https://status.webvaultcloud.com ✕

How to Test a New Website Using the Windows Hosts File

Creation date: 5/12/2023 3:19 PM    Updated: 4/02/2025 12:27 AM

When migrating a website from one hosting server to another, you may want to test its functionality on the new server before updating DNS records. This ensures that your existing site remains accessible to users while you verify the new setup.

Prerequisites

  • Obtain the IP address of your new web hosting server.

  • Use administrative privileges to edit system files.

Locating the Hosts File

On Windows, the hosts file is located at:

%SystemRoot%\system32\drivers\etc\hosts

Typically, this path translates to:

C:\Windows\System32\drivers\etc\hosts

Editing the Hosts File

To modify the hosts file and direct your computer to the new server:

  1. Click the Start menu.

  2. Select All Programs > Accessories.

  3. Right-click on Notepad and choose Run as administrator (this is required to edit system files).

  4. In Notepad, open the hosts file by navigating to:

    C:\Windows\System32\drivers\etc\hosts
  5. Change the file type to All Files (.) in the open dialog to see the hosts file.

  6. Open the file for editing.

Modifying the Hosts File

By default, the hosts file contains only the following lines:

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

To test your new website, add the following entries at the bottom of the file, replacing the IP addresses below with your new web server's IP (example only):

43.245.177.145    mydomain.com.au
43.245.177.145    www.mydomain.com.au

Saving and Testing

  1. Save the modified hosts file.

  2. Close and reopen your browser (or clear your DNS cache by running ipconfig /flushdns in Command Prompt).

  3. Open a fresh new browser window to avoid cached results.

  4. Visit your website by entering its domain name in the browser. Your computer should now connect to the new server.

Verifying Hosts File Entries

To ensure your system is resolving the domain to the new server:

  1. Open the Command Prompt (Press Win + R, type cmd, and press Enter).

  2. Run the following command, replacing mydomain.com.au with your domain:

    ping mydomain.com.au
  3. If the ping command returns responses from the new IP address, the hosts file is working correctly.

  4. If the old IP address appears, try clearing the DNS cache again (ipconfig /flushdns) and restarting your browser.

Finalizing Changes

Once you have verified that the new site functions correctly:

  1. Update your domain's DNS records to point to the new server.

  2. Remove the entries you added to the hosts file to prevent future conflicts.

  3. Save and close the hosts file.

By following these steps, you can safely test your website on the new server without affecting live users.

Public Knowledge base articles for customers to assist with managing their internet, email and IT cloud based services.