Accessing the Old Website or Server Using the Hosts File
In some scenarios, you may need to access the old website or server while it is still operational. For example, you might want to:
- Migrate data to the new site.
- Download a backup from the old server.
This guide explains how to temporarily edit your local computer’s hosts file to access the old server by pointing your domain to its old IP address.
Step 1: Find the Old Server’s IP Address
If you don’t already know the old server’s IP address, you can retrieve it using the following methods:
- Check the DNS records for the domain using a third-party tool like SecurityTrails and look for the historical IP address under the A record’s Last Seen data.
- Contact your previous hosting provider to request the old IP address.
Step 2: Edit the Hosts File
Once you have the old server’s IP address, follow the steps below to temporarily edit the hosts file on your local computer. This will allow your local machine to resolve the domain to the old server’s IP address.
For Windows
- Open Notepad as an administrator:
- Search for Notepad in the Start menu.
- Right-click and select Run as Administrator.
- Navigate to the file path:
C:\Windows\System32\drivers\etc. - Open the
hostsfile in Notepad. - Add the following line at the end of the file (replace
[OLD_IP]and[DOMAIN]with the old server’s IP address and your domain name):[OLD_IP] [DOMAIN]
Example:
123.45.67.89 example.com
- Save the file and close Notepad.
For Mac
- Open the Terminal application.
- Type the following command and press Enter to open the hosts file in the Nano editor:
sudo nano /etc/hosts
- Enter your password when prompted.
- Add the following line at the end of the file (replace
[OLD_IP]and[DOMAIN]with the old server’s IP address and your domain name):[OLD_IP] [DOMAIN]
Example:
123.45.67.89 example.com
- Press
Control + Xto save and exit.
Step 3: Flush the DNS Cache
After updating the hosts file, flush your DNS cache to ensure the changes take effect:
For Windows
- Open Command Prompt as an administrator.
- Type the following command and press Enter:
ipconfig /flushdns
- You should see a confirmation message that the DNS cache has been cleared.
For Mac
- Open the Terminal application.
- Type the following command and press Enter:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- There won’t be a confirmation message, but the DNS cache will be cleared.
Step 4: Access the Old Website
Now, when you visit your domain in a browser (e.g., http://example.com), your local computer will resolve it to the old server’s IP address. You can migrate data, download backups, or perform any required operations.
Step 5: Revert the Hosts File Changes
Once you have finished accessing the old server, remove the entry from your hosts file to ensure your computer resolves the domain to the new server. Follow the same steps as above to open the hosts file and delete the added line:
[OLD_IP] [DOMAIN]
Save the file and flush the DNS cache again to finalize the changes.
Conclusion
Editing the hosts file is a temporary solution for accessing an old website or server. Ensure you revert the changes to avoid confusion or potential issues in the future.
Need some help?
We all do sometimes. Please reach out to our support team by dropping us a support ticket. We will respond fast.