A common question asked in the various online discussion forums nowadays is “How do I shift/change hosts without any downtime?”. Well, here’s how to do it, step by step.
- Step 1 :
- Step 2 :
- Step 3 :
- Step 4 :
First, add your domain to the control panel of your new host. This way, you’ll ensure that their name servers are updated with your domain’s information, when you point your domain to your new host.
Put your site in read-only mode or maintenance mode. This way, you can ensure that your content do not change while you shift your files. Put up a short message informing visitors of the shifting of hosts. If your site consists of static HTML files, you do not need to worry about this.
Note : Most forums have an option for turning on the maintenance mode. For a WordPress blog, you might consider using the Maintenance Mode plugin.
Next, backup everything : your databases, files. If you use cPanel, use the Backup feature to backup your files and databases. You might also request your current host to backup your databases and files for you and they should probably do it. You can also manually download all your files using an FTP client and backup your databases with tools like phpMyAdmin.
Now upload the files into your new web host’s webspace. Most hosts provide a way of uploading your files and databases and view your site before the DNS changes propagate. However if your host does not provide you any such a way, you can take help of a little trick.
Note : This would not work unless you have performed the instructions in step 1 of this guide.
Take a note of your new host’s name servers. Let’s say, they are ns1.newhost.com and ns2.newhost.com. Now let’s query those name servers about your domain using the nslookup utility. Go to Start>Run and type in the following :
nslookup yourdomain.com ns1.newhost.com
Replace yourdomain.com with the name of your domain.
The query should output something like this :
Take a note of the IP address of mydomain.com. Now, go to ‘C:\WINDOWS\system32\drivers\etc’ and open the file named ‘hosts’ with a text editor. On a new blank line, add the following lines :
18.104.22.168 yourdomain.com 22.214.171.124 www.yourdomain.com
Replace yourdomain.com and 126.96.36.199 with their real-life equivalents.
Now your domain will be pointed to the IP address of your new host’s server only for you. Now you can upload your files, databases to your new host using yourdomain.com as the URL. After uploading everything, check whether your site is looking as it should and whether it’s generating any errors. If there is any errors or discrepancies, correct them. You should make a minor, but noticable change to your index file at your new host so that you can know if the DNS changes have propagated. After this you should remove the two lines from the ‘hosts’ file that you previously added to it, so that the domain resolves to your old host.
Now it’s time to change the DNS record of your domain. First we have to check if your new host’s name servers have been updated with records of your domain. For this, we need to run an nslookup query. Go to Start>Run and type in :
nslookup yourdomain.com ns1.newhost.com
If the query returns a non-authoritative answer or a “*** UnKnown can’t find yourdomain.com: Server failed” result, then your new host’s name servers haven’t updated yet. Use the same nslookup query to query the name servers again after some time. Repeat this process until it doesn’t return a non-authoritative answer or gives errors for your domain name. Usually, a name server updates itself every 15 minutes, but there may be exceptions. Now it’s safe to change your DNS records. Change your name servers to that of your new host’s OR change your A records to point your domain to your new host’s server’s IP, whichever you wish. The DNS changes will take around 24 to 48 hours to propagate around the world. You’ll know that the changes have propagated when you notice the minor change in your website which you did in Step 4.
Don’t delete your old hosting account yet. Until the DNS changes propagate around the world, people will go to your site hosted at your old host. It’s usually safe to delete your old hosting account after 5 days.
This pretty much concludes this article. If you face any problems while following the steps above, leave a comment and I’ll gladly help you.
See also : Automated website tools.