What the hosts file is all about

WordPress developers are often faced with the challenge of moving their sites across hosts. The process includes moving all your WordPress files and the database to a new server. It also involves a DNS update to reflect the IP address of the new server. This can result in downtime in case the update occurs before all the data has been moved to the new location. Even if the DNS update happens at the end of the entire process, there is always a likelihood that something went wrong. This again may result in downtime and put you under a lot of stress to resolve the issue quickly.

When you type a URL in the browser window, e.g. www.google.com, the step is to fetch the mapping IP address. This is achieved by means of a DNS lookup. A query is sent to the DNS server configured on your computer to get the IP address of the server we are trying to contact (i.e. google in this case).

There is an option to override the DNS lookup by using the hosts file. The hosts file stores the mapping between host names and IP address. The hosts file can be of great help to eliminate downtime while moving across hosts. It provides you with an opportunity to test your site on the new server before going live i.e. updating the DNS entry with the new server. Lets say you moved your site (e.g. https://blogvault.net) from server X to Y.  You can add a rule in your hosts file to map blogvault.net to the new server Y. Once this is done, the sitehttps://blogvault.net will be served by server Y, thereby enabling you to test all your changes. X and Y in this case would be IP addresses of the old and new server respectively.  blogvault.net  (Y’s IP address is

Note: Don’t forget to delete the entry from the hosts file once your testing is complete

Supposing you want to test blogvault.net as well as www.blogvault.net, you’ll need to add separate entries in the hosts file.  blogvault.net www.blogvault.net

The hosts file can be edited using any text editor that’s available on your system. Once you add the new lines, save them and proceed with your testing. Always remember to backup the hosts file before making any changes to it.


This file is found in different locations based on the OS that you’re running.

Unix, Linux and Mac/etc/hosts
Windows 8C:\Windows\System32\drivers\etc\

blogVault is a complete backup service that supports zero downtime migration. With just a click of a button, you can seamless move your site between hosts. To register with blogVault, click here.


Akshat is the Founder and CEO of BlogVault, MalCare, and WP Remote. These WordPress plugins, designed for complete website management, allows 100,000+ customers to build and manage high-performance websites with ease.

Copy link
Powered by Social Snap