Updating Your Hosts File: Exclusive Server Preview

February 23, 2024


Before going live with a website on a new server, you can point the domain to the new server’s IP address on your local machine. This allows you to test the site’s functionality, performance, and appearance on the new server without affecting the live site or the view of other users.

FOR MAC USERS:
WARNING DONT DO THIS IF YOU ARE NOT FAMILIAR WITH TERMINAL.

Step 1: Open Terminal

Command (⌘) + Space and typing “Terminal.”

Step 2: Edit the /etc/hosts File

In the Terminal, type the following:

sudo nano /etc/hosts

Press Enter. You will be prompted to enter your password. Note that you won’t see the characters as you type your password. This is normal for Terminal.

Step 3: Add the Entry

  • Add a new line with the IP address followed by the domain name you wish to point to that IP. In your case, it would look like this:
101.0.100.100 www.yourwebsite.com.au

Make sure to place the IP address first, followed by at least one space (or a tab), and then the domain name.

Step 4: Save and Exit

  • After adding the new line, save the changes by pressing Control (Ctrl) + O.
  • Press Enter to confirm the file name to write.
  • Exit nano by pressing Control (Ctrl) + X.

Step 6: Test the Changes

  • Open your web browser and navigate to the domain you updated. If everything was done correctly, your browser should now point to the new IP address you specified for the domain.
  • Keep in mind that these changes are local to your Mac only. Anyone else will still see the website hosted on the IP address defined by the domain’s public DNS settings.