When you’re moving to a new hosting server, the most important thing is to test your website before you point the domain to the new server. This will allow you to ensure a proper migration and verify that your site is functioning at 100% before you actually change the DNS.
DNS stands for Domain Name System. Here’s a post I wrote about what DNS is in-depth.
The instructions in this post involve editing the hosts file on your personal computer. Alternatively, you can use a third-party referral service that creates a proxy connection to the new server, such as SkipDNS.
Referring Using the hosts File on Your Personal Computer
The best way to test your website is to direct the domain to the IP of the new server through the hosts file on your computer. This action will save you from waiting for full DNS propagation, which can take quite some time.
However, note that this action will only be relevant for your personal computer. If someone else wants to access and test the site, they will also need to perform these actions of changing the hosts file.
Below you will find instructions for both macOS and Windows.
macOS Users
For macOS users, the location of the hosts file is:
/etc/hostsmacOS
Open the Terminal, and note that you need to make changes to this file as a superuser. To edit the hosts file using nano as a superuser, use the following command:
sudo nano /private/etc/hostsSince you’re performing an action as a superuser, you’ll be prompted to enter your macOS user password. Enter the password and press Enter.
Add the following lines at the bottom of the hosts file:
SERVER_IP_HERE example.com
SERVER_IP_HERE www.example.comReplace SERVER_IP_HERE with the IP address of the new server, and replace example.com with the domain name. It should look like this:
12.34.56.78 example.com
12.34.56.78 www.example.comOnce you’ve edited the hosts file, perform the following actions:
- Press CMD-X on the keyboard.
- Press Y to save the changes.
- Press the ENTER key.
That’s it. If you now access the domain in your browser, the redirection to the server with the IP you entered in the hosts file will occur. After you’ve finished testing, remember to remove these lines from the hosts file so that when you make the DNS changes, you can access the domain and server normally.
Windows Users
For Windows users, the hosts file is located at:
C:WindowsSystem32driversetchostsTo edit the file:
- Search for Notepad in the Start menu, right-click it, and select Run as administrator.
- In Notepad, go to File > Open and navigate to the directory above.
- Change the file type filter to All Files so the hosts file is visible.
- Add the following lines at the bottom of the file:
SERVER_IP_HERE example.com
SERVER_IP_HERE www.example.comReplace the values with your server IP and domain, then save the file (Ctrl + S) and close the editor.
Flushing the DNS Cache (If Needed)
If you still see the old site after editing the hosts file, your computer may be caching the previous DNS resolution. Flush the DNS cache to force a fresh lookup:
macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderWindows
ipconfig /flushdnsFlushing the cache ensures your computer loads the site from the new IP you entered in the hosts file.
You can also test your site on a new server using a temporary URL, but the hosts file method described in this post is more reliable since it uses your actual domain.
FAQs
Common questions about testing sites before DNS changes:
Summary
Testing your WordPress site on a new server before changing DNS is a critical step to ensure a smooth migration. By editing the hosts file on your computer, you force your browser to load the site from the new server using your actual domain, without waiting for global DNS propagation.
The process works on both macOS and Windows. If changes do not take effect immediately, flush your DNS cache. Once you have verified that everything functions correctly on the new server, remove the hosts file entries and update your DNS records to complete the migration.

