Migrating between WordPress hosts without downtime
Sometimes you'll want to migrate WordPress hosts - maybe it's time for renewal, and you found a better deal elsewhere, or your hosting provider isn't as reliable as they promised.
Which is great for you, but your site's readers don't care that it's a better deal - they just want to see your content. So minimising downtime when transferring hosts is a pretty big deal.
Let's learn how to avoid downtime.
The first step is to transfer your content to your new host, without turning off the old host. Your site on your old hosting provider doesn't have to be shutdown for you to start standing up your site on the new hosting provider.
Whether that's via a plugin, and manually copying your files across using FileZilla, or by getting a developer to copy your database to the new host, you need to have two copies of your site running to avoid downtime.
At the end of this step you should have two WordPress sites:
- The old one, which your domain is still pointing to (as in, visiting https://yoursite.com still shows your WordPress site on your old hosting provider)
- The new one, with a weird URL (depending on your new provider, this could be an IP address, or just a testing URL)
The last thing you want is to realise you forgot to copy your images after your site's users start visiting the new site.
Click around your new WordPress site, ensure images work, pages and posts are all there with the URLs you expect.
Once you're satisfied the new site works as you expect, you're ready to update your DNS
This step will be different depending on your domain registrar (the company you bought the domain from), but the gist of it is that you're changing the address your domain points to from your old hosting provider, to the new one.
This step can take up to 72 hours for some old school providers, and can be as quick as a few minutes with AWS or CloudFlare. The time it takes is due to the DNS TTL values you use - you can read more about that here. You can speed this step up by setting your TTL to a low value (like 300 seconds or 5 minutes) before you start the migration.
You can test whether the new hosting provider is live by creating a dummy blog post or page using the same URL you tested your new hosting provider with - if the post shows up at https://yoursite.com, your new site is live!
Once you're absolutely sure your domain is displaying the WordPress site from your new hosting provider, then you can turn off the WordPress site running at your old hosting provider.
Essentially by not turning off either WordPress site, you entirely avoid downtime. When you switch the DNS records from the old hosting provider over to the new one, people visiting your site just start seeing the new site (since you don't turn off the old site until the migration is complete).