Skip to content

How to Migrate WordPress to a New Host With Zero Downtime

Migrate WordPress to a new host with zero downtime: full backups, WP-CLI search-replace, hosts file previews, DNS TTL timing and keeping email records intact.

By Devma Hosting Team · · 10 min read

A sunlit desk with a closed laptop, an external hard drive, network cables and an open moving box, suggesting a careful website move to a new host.

To migrate WordPress to a new host with zero downtime, you build a complete, tested copy of your site on the new server while the old one keeps serving visitors, then switch only the DNS records that point at the website. Lower your DNS TTL a day or more ahead, freeze content during the final sync, and leave your MX and other email records alone so mail keeps flowing.

Key takeaways

  • Back up both the WordPress files (themes, plugins, uploads, wp-config.php) and the database, and test that the backup actually restores before you rely on it.
  • If your domain and URLs stay the same, a search-replace is usually unnecessary. Run WP-CLI's wp search-replace only for temporary URLs, http to https changes or changed server paths, always with --skip-columns=guid and a --dry-run first.
  • Preview the new server by mapping your domain to its IP in your computer's hosts file, so you can test everything before the public sees it.
  • Lower the A and AAAA record TTL (for example to 300 seconds) at least one full old-TTL period before the switch, then change those records rather than your nameservers.
  • Keep every MX, SPF, DKIM, DMARC and verification record intact, and keep the old host running until traffic and mail stop reaching it.

What does zero downtime mean when you migrate WordPress?

DNS changes don't reach everyone at once. Resolvers around the world cache your records until their TTL expires, so for a while some visitors reach the old server and some reach the new one. Zero downtime means both servers serve the same working site during that window, so nobody notices which one they hit.

That gives you three goals: an identical copy on the new host, a short and predictable DNS switch, and no changes to the records that handle email. The steps below follow the order you should do them in.

Before you start: a WordPress migration checklist

Item Where to find it Why it matters
All current DNS records (A, AAAA, CNAME, MX, TXT, SRV) Your DNS provider's dashboard, or our DNS Lookup tool You need a full copy before touching anything
Current TTL on A and AAAA records DNS dashboard or dig Decides how early you lower it
PHP and database versions on the old host Tools > Site Health > Info Match or upgrade on the new host
Database name, user, host and table prefix wp-config.php Needed to connect on the new server
SSH or SFTP access to both servers Each host's control panel Required for WP-CLI and file transfers
Cron jobs and scheduled tasks Old host's control panel Recreate later, but never run on both servers at once

WordPress currently recommends PHP 8.3 or newer, MariaDB 10.11+ or MySQL 8.0+, and HTTPS. If the new host runs a newer PHP version than the old one, confirm your theme and plugins support it before the cutover, not after.

Step 1: Lower your DNS TTL a day or more ahead

TTL (time to live) is how long, in seconds, resolvers may cache a record. Check your current values:

dig +noall +answer example.com A
dig +noall +answer www.example.com A

The number after the hostname is the TTL. If it reads 86400, resolvers can hold on to the old IP for up to 24 hours.

Lower the TTL on your A and AAAA records (including www) to something short, such as 300 seconds. Timing is everything here: do it at least one full old-TTL period before the switch. Lowering the TTL at the same moment you change the IP does nothing, because resolvers are still holding the old record with the old, long TTL. Providers set their own minimums, so check yours, for example Cloudflare's TTL reference.

Step 2: Take a full backup and test the restore

WordPress's own migration guide starts with backing up the WordPress directory, images, plugins and other files, plus the database. Both halves matter: the files hold uploads, themes and configuration, and the database holds posts, settings, users and orders.

On the old server, with WP-CLI:

cd /home/olduser/public_html
wp db export ~/migration/site-db.sql
tar -czf ~/migration/site-files.tar.gz .

Download a copy to somewhere that isn't either server. Then prove it works by restoring it to a local environment or scratch database and loading a page. An untested backup is only a hope.

Step 3: Move the files and database to the new host

Copy the files

If both servers have SSH, rsync is fast and can be re-run later to pick up only what changed:

rsync -avz --progress olduser@old-server.example.net:/home/olduser/public_html/ /var/www/example.com/

Make sure hidden files come across, especially .htaccess, which holds the Apache rewrite rules your permalinks depend on. If the new server runs Nginx, add the equivalent WordPress rewrite rules to its server configuration instead.

Import the database

Create an empty database and user on the new host, upload the SQL file, then import it:

cd /var/www/example.com
wp db import ~/migration/site-db.sql

Update wp-config.php

Edit DB_NAME, DB_USER, DB_PASSWORD and DB_HOST for the new server. Keep $table_prefix exactly as it was, and keep DB_CHARSET (usually utf8mb4) consistent so special characters and emoji survive. Then confirm WordPress can connect:

wp db check
wp option get siteurl

Step 4: Decide whether you need a search-replace

This is the step most guides overstate. The WordPress migration documentation notes that moving a site without changing the Home and Site URLs is very simple and, in most cases, just means moving the files. If you keep the same domain and protocol, your URLs are already correct.

You only need a search-replace if:

  • the site was built or tested on a temporary or staging URL,
  • you're switching from http to https, or between www and non-www, or
  • plugins stored absolute server paths (such as /home/olduser/public_html) and the new path is different.

How to run WP-CLI search-replace safely

Never run find-and-replace on the SQL dump with sed or a text editor. WordPress stores many settings as PHP serialized data, which records the length of each string. Change the text without updating the length and the data breaks. WP-CLI's search-replace command handles serialized data correctly.

# 1. Snapshot the database first
wp db export before-search-replace.sql

# 2. Preview what would change
wp search-replace 'https://staging.example.com' 'https://example.com' --skip-columns=guid --all-tables --dry-run

# 3. Run it for real
wp search-replace 'https://staging.example.com' 'https://example.com' --skip-columns=guid --all-tables

# 4. Clear cached values
wp cache flush

A few things worth knowing:

  • --skip-columns=guid leaves post GUIDs alone. WordPress advises against changing them, because feed readers use GUIDs to identify posts.
  • By default the command only touches tables registered with WordPress. --all-tables includes plugin tables with other prefixes. If the database is shared with other apps, pass a table wildcard such as 'wp_*' instead.
  • Tables without a primary key are skipped, so spot-check any plugin data that lives in them.
  • Avoid --regex unless you need it, since the official docs note it makes the run much slower.
  • For a server path change, do a second pass, for example from '/home/olduser/public_html' to '/var/www/example.com'.

Step 5: Preview the new server through your hosts file

Your hosts file tells your computer to ignore public DNS for specific names. Point your domain at the new server's IP and you'll see the new site on the real domain, while everyone else still sees the old one. There's no temporary URL involved, so testing doesn't force a search-replace.

Add both names, using the new server's IP:

203.0.113.10 example.com
203.0.113.10 www.example.com
System File location How to edit
macOS /private/etc/hosts sudo nano /private/etc/hosts
Linux /etc/hosts sudo nano /etc/hosts
Windows C:\Windows\System32\drivers\etc\hosts Run Notepad as Administrator, then open the file

Next, flush your DNS cache: ipconfig /flushdns on Windows, or sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder on macOS. Browsers using Secure DNS (DNS over HTTPS) and VPNs can occasionally get in the way, so confirm you're really on the new server. Check the remote address in your browser's developer tools (Network tab), or upload a small test file that only exists on the new host.

Now test properly:

  1. Log in to wp-admin and check the dashboard loads without errors.
  2. Open a range of pages, posts and archive pages, and check images load.
  3. Visit Settings > Permalinks and save once to confirm rewrite rules work.
  4. Submit a contact form and, if you sell online, run a test checkout.
  5. Make sure Settings > Reading does not have "Discourage search engines" ticked.

Remove the hosts entries when you finish, or you'll keep seeing the new server and miss problems other visitors report.

Step 6: Get SSL ready before the switch

If the new host issues Let's Encrypt certificates with the HTTP-01 challenge, validation can't succeed until DNS points at the new server. Many hosts' automatic SSL works the same way. You have three options:

  1. Use the DNS-01 challenge, which proves control of the domain through a TXT record and works before the switch.
  2. Copy the existing certificate and private key from the old server.
  3. Accept a short gap and issue the certificate immediately after the switch.

Options 1 and 2 keep the move truly seamless. Once you're live, confirm the certificate chain and expiry date with our SSL Checker.

Step 7: Keep MX and email records intact

Email is where most simple-looking migrations go wrong. Your website and your mail usually rely on different DNS records, and you only want to change the website ones.

Before changing anything, export or screenshot every record:

  • MX records
  • SPF (a TXT record starting with v=spf1)
  • DKIM (TXT or CNAME records, usually under selector._domainkey)
  • DMARC (a TXT record at _dmarc)
  • Autodiscover and autoconfig records
  • Verification TXT records and any SRV records

Watch for a common trap: an MX record pointing to mail.example.com, where mail is an A record or CNAME for the same IP as the website. Move the web server and you've quietly moved mail too. Point mail. directly at your mail server's IP before the cutover.

Then think about mail WordPress sends itself: password resets, form notifications and WooCommerce receipts. If the new server sends directly, add its IP to your SPF record, or better, send through an authenticated SMTP or transactional email service. Major mailbox providers such as Google require sender authentication, so unauthenticated mail from a new IP is likely to land in spam. Our SPF & DMARC Generator can help you build correct records.

Step 8: Freeze content and run a final sync

Anything that changes on the old site after your export (orders, comments, form entries, edited posts) won't exist on the new server. Pick a quiet time, then:

  1. Pause content changes. Ask editors to stop publishing, and on a store consider a short maintenance notice on checkout.
  2. Re-export the database on the old server and import it on the new one.
  3. Re-run the rsync command to catch new uploads.
  4. Repeat the search-replace if your migration needed one.

Step 9: Switch the A and AAAA records, not the nameservers

Now update only the records that point at the website:

  • the A record for example.com and for www (or the www CNAME),
  • the AAAA record if you use IPv6. Forget this one and some visitors will keep reaching the old server.

Wherever possible, change these records at your current DNS provider instead of moving nameservers to the new host. NS records are cached by the parent zone (such as .com) with long TTLs you can't lower, and a nameserver move is the easiest way to lose MX and TXT records. If you must move nameservers, recreate every record at the new provider first and compare both sides with DNS Lookup.

Verify against a couple of public resolvers:

dig +short example.com A @1.1.1.1
dig +short example.com AAAA @8.8.8.8
dig +short example.com MX

The MX answer should be exactly what it was before the move.

Step 10: Watch both servers, then retire the old host

During propagation both servers are live, so tidy up a few things:

  • Cron jobs: WP-Cron or system cron running on both servers can send duplicate emails and repeat scheduled tasks. Once traffic has moved, add define( 'DISABLE_WP_CRON', true ); to the old site's wp-config.php and remove its system cron entries. Recreate the real cron jobs on the new host.
  • Caches: clear the page cache, object cache (such as Redis) and any CDN cache on the new setup.
  • Logs: watch the old server's access and mail logs.

Keep the old hosting account until those logs show nothing reaching it, typically several days to a week. Then raise your TTL back to a normal value and cancel the old plan.

Moving your WordPress site to Devma Hosting

If you're weighing up where to move, take a look at our WordPress Hosting plans. Whichever host you choose, confirm before you start that your plan gives you SSH access and WP-CLI, because most of the steps in this checklist depend on them.

Frequently asked questions

How long does it take to migrate WordPress to a new host?

The hands-on time varies with the size of your uploads folder and database, your access to both servers, and how much testing you do. The real lead time comes from DNS: you should lower your TTL at least one full old-TTL period before the switch, which can mean a day or more of waiting. After the cutover, plan to keep the old host running for several days to a week.

Can I use a migration plugin instead of WP-CLI?

Yes, many backup and migration plugins package your files and database and restore them on the new server. They work differently from the manual WP-CLI method, so follow one approach from start to finish rather than mixing steps. The DNS, hosts file, SSL and email steps in this guide apply either way.

Will moving WordPress to a new host hurt my SEO?

A host move on the same domain with the same URLs and no downtime should not change your rankings by itself. Problems usually come from mistakes, such as leaving the Discourage search engines setting enabled on the new site, broken permalinks or a missing SSL certificate. Test those before and right after the switch.

What PHP and database versions should my new WordPress host run?

WordPress recommends PHP 8.3 or newer, MariaDB 10.11+ or MySQL 8.0+, and HTTPS support. Match or upgrade the PHP version you run today, and confirm your theme and plugins support it before you change DNS. Older versions may still run WordPress but are not the recommended setup.

Abstract blue swirling shapes with light reflections

Ready when you are.

Pick a plan and launch today, or tell us what you run and we will size it with you.

Devma Hosting

AI assistant · replies in seconds

Hi there.
How can we help?

Ask about plans, moving your site, email or security. Answers come from our own guides, and a person is one tap away.

  • Message us on WhatsApp