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.
Obtain the IP address of your new web hosting server.
Use administrative privileges to edit system files.
On Windows, the hosts file is located at:
%SystemRoot%\system32\drivers\etc\hostsTypically, this path translates to:
C:\Windows\System32\drivers\etc\hostsTo modify the hosts file and direct your computer to the new server:
Click the Start menu.
Select All Programs > Accessories.
Right-click on Notepad and choose Run as administrator (this is required to edit system files).
In Notepad, open the hosts file by navigating to:
C:\Windows\System32\drivers\etc\hostsChange the file type to All Files (.) in the open dialog to see the hosts file.
Open the file for editing.
By default, the hosts file contains only the following lines:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhostTo 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.auSave the modified hosts file.
Close and reopen your browser (or clear your DNS cache by running ipconfig /flushdns in Command Prompt).
Open a fresh new browser window to avoid cached results.
Visit your website by entering its domain name in the browser. Your computer should now connect to the new server.
To ensure your system is resolving the domain to the new server:
Open the Command Prompt (Press Win + R, type cmd, and press Enter).
Run the following command, replacing mydomain.com.au with your domain:
ping mydomain.com.auIf the ping command returns responses from the new IP address, the hosts file is working correctly.
If the old IP address appears, try clearing the DNS cache again (ipconfig /flushdns) and restarting your browser.
Once you have verified that the new site functions correctly:
Update your domain's DNS records to point to the new server.
Remove the entries you added to the hosts file to prevent future conflicts.
Save and close the hosts file.
By following these steps, you can safely test your website on the new server without affecting live users.