Example :
How to set up an email or change my account settings.
- Help Center
- Web Hosting
- Hosting Migration
- How to View your Z.com website using a hosts file
How to View your Z.com website using a hosts file
*In case of Preview Your Website Before DNS Propagation Completes
The hosts file is a text file on operating systems like Windows, macOS, and Linux that maps hostnames to IP addresses, allowing manual DNS overrides. Editing it can redirect domain names to specific servers.
For WordPress users, leveraging the hosts file is advantageous when migrating a website to a different hosting provider or changing the domain’s nameservers. For instance, when moving from Host A to Host B (where Host A is the old Server and Host B is the new Server) location. You need to migrate your website’s files and then update your domain’s nameservers to point to Host B instead of Host A.
DNS changes can take time to spread worldwide, so your domain might still direct you to the old host (Host A) instead of the new one (Host B) where your website is migrated. By editing the hosts file, you can manually link your website’s domain to the new server’s IP address, allowing you to test the new site immediately without waiting for DNS propagation to take effect.
Find the location of your hosts file (Hosts File Locations by Operating System)
• Windows (10, 8, 7, XP, etc.)
Location: C:\windows\system32\drivers\etc\hosts
• Apple macOS
Location: /private/etc/hosts
*In terminal, enter the command and then press enter: sudo nano /private/etc/hosts
• Linux
Location: /etc/hosts
*Same steps as for macOS, use the command sudo nano /etc/hosts
Let’s take Windows 10 as an example
1. Click [Start] and search for [Notepad].
2. Right-click and select [Run as administrator].
*You will be prompted to confirm on the pop-out message [This app to make changes to your device], click [Yes] to proceed.
3. Once in Notepad, go to File -> Open. Navigate to C:\Windows\System32\Drivers\etc. By default host file is hidden, select [All Files] to show, choose [hosts] then click open to proceed.
4. Add an entry in your hosts file for your domain and the Z.com site IP (hosting server IP), using the following format:
Add Z.com site IP address (Server IP), followed by a space, replace (example.com) with your own domain name.
[your Z.com site IP] [your domain name]
For example,
163.44.242.9 example.com
5. Save the new changes to your hosts file.
*Flush the DNS Cache (if needed): To ensure that your system starts using the changes.
6. Access your domain name through any web browser of your choice. The website files from your hosting account will load, allowing you to preview your website.
After completing these steps, your PC will redirect requests for your Z.com domain to the specified IP address as per the hosts file entry.
Let’s take Mac OS as an example
If you’re using a Mac OS, follow steps below to edit hosts file:
1. Open [Terminal] application by going to [Finder], click [Go] then [Utilities].
2. Double-click [Terminal] to open the Terminal window.
3. Enter any of the commands below, then enter your computer password when prompted. Simply type your password. The cursor will remain in a blinking state. Press Enter once you have entered your password.
sudo nano /etc/hosts
or
sudo nano /private/etc/hosts
4. Use the arrow keys to move the cursor to the bottom then, Add Z.com site IP address (Server IP), followed by a space, replace (example.com) with your own domain name.
[your Z.com site IP] [your domain name]
For example,
163.44.242.9 example.com
5. Follow the instruction on the bottom of the window to save changes or [Control+O] to replace the current host file, then press Enter to confirm. Lastly press [Control+X] to exit the host editor, and you are done editing your macOS host file.
Note: Once done with the website testing, or when the DNS is totally propagated worldwide. Ensure to remove or comment out this entry in the hosts file, to allow your computer to access the website normally under the new server host.