Problem
You have an existing WordPress website at example.com and you are building a new website on a different server. You’d like to keep all the settings at example.com, but you have no way of viewing your website.
Solution
Tell your computer, by updating its host file to resolve the example.com to the IP address of your website on the new server. This way when you go to example.com on your computer you are automatically brought to the new website.
Steps to Solve:
Step #1:
Find the Host File on Your Operating System
- Windows: typically C:\Windows\System32\drivers\etc\hosts if you can’t find it there you’re looking for: SystemRoot > system32 > drivers > etc > hosts
- Linux: /etc/hosts
- Mac OS X: /private/etc/hosts
Step #2:
Determine the IP address you’d like example.com to resolve
Step #3
Update the hosts file with the IP and the URL
If the IP address you’d like to resolve to is 1.2.3.4 and the domain is example.com you would enter as the hosts file entry:
1.2.3.4 example.com www.example.com
Then you should be able to enter example.com and see your website. You may need to clear your browser’s cache if you’re having issues.
Windows 8 and 10:
- Open the Start Menu
- Search for Notepad
- Right Click and Run As Administrator
- While in Notepad open the Hosts file (you may need to select “All Files” in the file type in-order to see the file)
- Open the Host file and enter the hosts file entry
Linux
- Open up the Terminal
- Enter
sudo nano /etc/hosts
- Add the changes to the host file
- Use
Ctrl + X
to save the changes
Mac X 10.6 through 10.12
Start by logging in as an administrator
- Open Applications > Utilities > Terminal
- Edit the hosts file with a command line text editor like nano by typing:
sudo nano /private/etc/hosts
- Add your changes at the bottom of the file
- Save by changes with Control + X key combination followed by Y and then Enter
This article helped us create this post: https://www.siteground.com/kb/hosts-file/