Testing your website on a new server before changing DNS

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.

In this post, we’ll see how to perform the actions on the macOS operating system only. If you need assistance with other operating systems, feel free to ask us specific questions in the comments below.

macOS Users

For macOS users, the location of the hosts file is:



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/hosts

Since 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.com

Replace SERVER_IP_HERE with the IP address of the new server, and replace example.com with the domain name. It should look like this: example.com www.example.com

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

Roee Yossef
Roee Yossef

I develop websites & custom WordPress themes by design. I love typography, colors & everything between, and aim to provide high performance, seo optimized websites with a clean & semantic code.


Leave a Comment