How to preview your website before updating nameservers (Mac – Hosts File)
When migrating your website to Papaki (or moving to a new hosting plan), it is best practice to verify that everything works properly before updating your domain's Nameservers at your registrar.
By modifying the hosts file on your Mac, you can instruct your computer to resolve your domain directly from the new server's IP address at Papaki, without affecting any other visitors on the web.
What You Will Need:
- Your new server IP address: You can find this in your hosting activation email or inside your hosting management panel (Plesk / cPanel / Control Panel).
- Your Mac administrator password.
Step-by-Step Guide to Modifying the Hosts File on Mac:
Step 1: Open Terminal
- On your Mac, open Finder and navigate to Applications > Utilities > Terminal
(or press Cmd + Space to open Spotlight, type Terminal, and press Enter).
Step 2: Open the hosts file with administrative privileges
- In the Terminal window, paste the following command and press Enter:
sudo nano /private/etc/hosts
- When prompted, type your Mac user password.
Note: For security reasons, no characters or cursor movements will appear on screen while typing your password. Type it normally and press Enter.
Step 3: Add your server IP and domain name
- Use the arrow keys on your keyboard (down arrow) to navigate to the bottom of the file (below the
127.0.0.1 localhost entry).
- Add two new lines containing your Papaki server IP address followed by your domain name (both with and without
www), as shown below:
123.45.67.89 yourdomain.gr
123.45.67.89 www.yourdomain.gr
(Replace 123.45.67.89 with your actual server IP address and yourdomain.gr with your domain).
Step 4: Save and exit
- Press Ctrl + O (the letter O) to write the changes.
- Press Enter to confirm the filename.
- Press Ctrl + X to close the nano text editor and return to the command prompt.
Step 5: Test your website
- Open your web browser (Safari, Google Chrome, or Mozilla Firefox).
- It is recommended to open a Private / Incognito window so the browser does not read cached DNS data.
- Type your domain name in the address bar. Your Mac is now loading the website directly from your new Papaki server!
How to Revert the Hosts File to Its Original State
Once you have finished testing and you are ready to update the Nameservers:
- Repeat Steps 1 and 2 to open the file in Terminal.
- Use the arrow keys to navigate to the lines you added, and delete them (
Backspace or Delete).
- Press Ctrl + O, then Enter, and finally Ctrl + X to save and exit.
Flush DNS Cache:
If your Mac continues to resolve the old IP address after modifying or reverting the hosts file, flush your Mac's DNS cache by running this command in Terminal:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder