WordPress

How to migrate WordPress to a new host without downtime

Most WordPress migrations go wrong at the same few points: an incomplete backup, a DNS switch before the new site was tested, or email records lost along the way. This plan avoids all three and keeps the site online throughout.

Illustration: a website card gliding along a path of light from an old grey server to a bright new one

Migrating WordPress means copying two things to the new host, the files (above all wp-content) and the database, then pointing your domain at the new server. Done in the right order, visitors never see an outage: the old site keeps serving traffic until the new one has been tested, and DNS moves over only at the end.

The short plan:

  1. Lower your DNS TTL a day or two ahead.
  2. Back up the files and the database on the old host.
  3. Copy both to the new host and connect them in wp-config.php.
  4. Test the new site privately using your computer's hosts file.
  5. Put a valid SSL certificate on the new host before the switch.
  6. Freeze changes, do a final sync, switch DNS, and keep the old account for a week or two.

Below, each step in detail, with the commands for people who have SSH and the plugin route for people who do not.

Before you start: check the new host

Make sure the new server can run your site before you copy anything.

  • PHP version. Use the version your theme and plugins support, ideally the same one or newer than you run now. You can see it under Tools → Site Health → Info → Server in your WordPress dashboard.
  • Database. WordPress recommends a current MySQL or MariaDB release. A similar version to your old host avoids surprises with character sets and collations.
  • Memory and limits. Compare memory_limit, upload size and PHP worker limits with your current host. The WordPress memory calculator estimates what your plugin set needs.
  • Disk space. Enough for the site, the database and at least one backup archive.
  • Web server. If you move from Apache to Nginx (or LiteSpeed), rules in .htaccess stop working. Redirects, security rules and caching plugins that write to .htaccess need equivalents in the new server's configuration. Also note any server cron jobs on the old host and recreate them.
  • Email. Decide now whether your email stays where it is. If mail is hosted with your old web host, it needs a migration plan of its own (see below).

Step 1: Lower the DNS TTL

The TTL (time to live) on a DNS record tells resolvers how long to cache it. If your A record has a TTL of a day, some visitors keep reaching the old server for up to a day after you change it.

At least one full TTL period before the move (24 to 48 hours ahead is common), lower the TTL on the records for your domain and www, for example to 300 seconds. Then, on moving day, the change spreads within minutes. You can raise it again once the move has settled.

If you will also change nameservers rather than just the A record, the nameserver change has its own cache time at the registry, which you cannot shorten. Changing records at your current DNS provider is the faster option where you have the choice.

Step 2: Make a complete backup

You need every file and a consistent copy of the database.

A website and its database being packed together into a sealed box
A WordPress backup is two parts: the files, above all wp-content, and the database. One without the other cannot be restored.

With SSH and WP-CLI on the old host:

cd /path/to/wordpress
wp db export ~/site-db.sql
tar czf ~/site-files.tar.gz .

wp db export reads the credentials from wp-config.php and runs mysqldump for you. Without WP-CLI, use mysqldump directly:

mysqldump --single-transaction --default-character-set=utf8mb4 -u DB_USER -p DB_NAME > ~/site-db.sql

--single-transaction takes a consistent snapshot of InnoDB tables without locking the site.

Without SSH: download the files over SFTP (the whole WordPress directory, including hidden files such as .htaccess), and export the database from phpMyAdmin in your control panel. A migration plugin can package both for you; that is fine for small and medium sites, but very large sites often hit upload or time limits, and the manual route is more reliable.

Keep a copy of the backup on your own computer, not only on the old server.

Step 3: Copy the site to the new host

Files. Upload the archive and unpack it into the new site's document root, or copy directly between servers:

rsync -av -e ssh ~/site-files.tar.gz user@new-server:~/
# on the new server:
cd /path/to/new/site && tar xzf ~/site-files.tar.gz

Check that the files belong to the user the web server runs as, so WordPress can write uploads and updates. Your control panel or host's documentation tells you which user that is.

Database. Create an empty database and user on the new host, then import:

wp db import ~/site-db.sql
# or: mysql -u NEW_USER -p NEW_DB < ~/site-db.sql

Connect them. Edit wp-config.php on the new host with the new DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. Leave the security keys and the table prefix ($table_prefix) as they are.

If the domain stays the same, nothing else needs changing. Your posts and settings still point to the right URLs.

Step 4: Test before anyone else sees it

This is the step that removes the risk. Your hosts file can point your computer only at the new server, while everyone else still reaches the old one.

Add a line with the new server's IP address and your domain:

203.0.113.25  example.com www.example.com

The file is /etc/hosts on macOS and Linux, and C:\Windows\System32\drivers\etc\hosts on Windows (edit it as Administrator). Then open your site in a private browser window and check:

  • The home page, a few posts and pages, and images.
  • Logging in to /wp-admin and saving a draft.
  • Forms, search and, for WooCommerce, the cart and checkout in test mode.
  • Permalinks. If posts return 404, re-save Settings → Permalinks or run wp rewrite flush.

HTTPS may show a certificate warning at this stage, because the new server has no certificate for your domain yet. That is expected; the next step fixes it before anyone else arrives. Remove the hosts file line when you have finished testing.

Step 5: Put SSL in place before the switch

If the new server has no valid certificate when DNS changes, visitors who reach it see a security warning, and browsers that remember your site's HSTS setting refuse to load it at all. That is downtime, so get the certificate ready first. Any of these works:

  • Your host's pre-migration SSL. Many hosts and panels can issue a certificate before the domain points at them, usually by asking you to add a DNS record.
  • DNS validation. Let's Encrypt can prove ownership through a TXT record instead of a web request (the DNS-01 challenge), so the certificate can be issued while the site still runs on the old host.
  • Copy the current certificate. If you have the old certificate and its private key, install them on the new server for now, and switch to automatic renewal there once DNS has moved.

Test again through the hosts file: the padlock should now show without a warning.

Step 6: Final sync and the DNS switch

If the site changes often (new posts, comments, orders), anything that happens on the old site after your backup is missing from the new one. For a blog, schedule the move for a quiet time and avoid publishing until it is done. For a shop, put the old site in maintenance mode, export the database again, re-sync wp-content/uploads, and import both on the new host. Keep the old site in maintenance mode until traffic has moved over, because some visitors keep reaching the old server for a while; an order placed there after the final export would otherwise be lost.

A switch lever pointing traffic away from a dim old server to a bright new one
The DNS change is the last step, not the first: by then the new server is tested and has its certificate.

Then change the A record (and AAAA if you use IPv6) for the domain and www to the new server's address. With a low TTL most visitors arrive at the new server within minutes; allow a few hours for everyone.

Keep your email working

Website hosting and email are often separate services that share one DNS zone. When you move the site:

  • If you only change the A records, your MX, SPF, DKIM and DMARC records stay as they are and email is unaffected.
  • If you move DNS to a new provider or new nameservers, copy every record across first, including MX, TXT verification records and any CNAME records used by your email service.
  • If your mailboxes are hosted by the old web host, they stop working when you cancel it. Move them to the new host or a separate email provider before you cancel.

After the switch: checks and cleanup

Once DNS points to the new server:

  • Make sure certificate renewal runs automatically on the new host (if you copied the old certificate, set up a new one now).
  • Check that http:// redirects to https:// and that the browser shows no mixed-content warnings.
  • Clear any caching plugin and CDN cache.
  • Watch Google Search Console for crawl errors over the following days.
  • Set up backups on the new host before you rely on it.
  • Raise the DNS TTL back to its usual value.

Keep the old hosting for one to two weeks before cancelling. It is your fallback, and some resolvers ignore TTLs. Check the old server's access log: when it stops receiving visitors, you can let it go.

If the domain is changing too

Moving to a new domain at the same time adds one step: replace the old URL in the database. Do not do this with a text editor on the SQL file, because WordPress stores some settings as serialized PHP data, and changing the length of a string breaks it. WP-CLI handles serialized data correctly:

wp search-replace 'https://old-domain.com' 'https://new-domain.com' --skip-columns=guid --dry-run

Check the report, then run it again without --dry-run. Skipping the guid column is the WordPress recommendation: those values identify posts to feed readers and should not change. Then set up 301 redirects from the old domain to the new one, page for page, so visitors and search engines follow. Add the new domain in Google Search Console, submit its sitemap, and use the Change of Address tool.

A migration checklist

  • New host meets PHP, database and memory needs
  • DNS TTL lowered at least a day before
  • Full backup of files and database, with a copy off the server
  • Files and database copied, wp-config.php updated
  • Site tested through the hosts file, including logins and forms
  • Valid SSL certificate on the new host before the switch
  • Final sync done, A/AAAA records changed
  • Email records preserved; mailboxes moved if they lived on the old host
  • HTTPS redirect working, renewal automatic, caches cleared
  • Backups running on the new host
  • Old hosting kept for one to two weeks

Still choosing where to move? The WordPress hosting page lists requirements and plans that fit, and the price explorer compares current prices.

Sources