Move WordPress without downtime
Downtime happens when DNS switches before the new host is ready, or when the old host goes away before DNS has spread. Both are avoidable.
1. Lower the DNS TTL a day before
At your DNS provider set the TTL of the A record (or the records you will change) to 300 seconds. Wait at least the old TTL before continuing, often 24 hours.
2. Copy the site to the new host
Move files and database using the host's migrator or by hand. Leave the old site live and unchanged.
3. Plan HTTPS on the new host
The new host needs a certificate for your domain, or visitors see a security warning after the switch. Many hosts can only issue it once the domain points to them. Then ask the host to issue it right after the DNS change.
When you test with the hosts file before that, the browser can show a certificate warning. That is expected.
4. Test with your hosts file
Map the domain to the new host's IP in your computer's hosts file. Only your computer sees the new server.
# /etc/hosts (Mac, Linux) or C:\Windows\System32\drivers\etc\hosts 203.0.113.10 yourdomain.com www.yourdomain.com
Load the site, log in, open posts, upload an image, send a form. Remove the line afterwards.
5. Freeze changes
Stop publishing, stop editing, and if the site takes orders or comments, put it in maintenance mode on the old host. Then do a final database export and import so both hosts match.
6. Switch DNS
Change the A record to the new IP. With a 300 second TTL most visitors reach the new host within minutes.
7. Keep the old host for a few days
Both hosts now serve the same site. Visitors with cached DNS still land on the old one and see the same content. After a few days, check the old host's access log is quiet, then cancel.