WordPress

How to migrate WordPress to a new host without downtime

Back up, copy, test on the new server before anyone is sent there, then switch DNS. And do not forget the email.

A laptop showing a file transfer progress bar between two servers
Share
In this article
  1. Before you start: back up and take inventory
  2. Lower the DNS TTL a day before
  3. Three ways to copy the site
  4. If the domain changes, use search-replace the right way
  5. Test the new copy before switching DNS
  6. Switch DNS
  7. What to check after the switch
  8. Online stores: orders during the move
  9. Keep the old hosting for a week or two

The safe order is: take a full backup and list everything the old host does for you, lower your DNS TTL a day ahead, copy the site to the new host, test the copy through your computer's hosts file, and only then switch DNS. Visitors keep reaching the old server until DNS updates, so the site never goes down, and the old hosting stays active for a week or two as a safety net.

Before you start: back up and take inventory

Make a full backup of the files and the database, and store it somewhere other than the old host. If you are not sure the backup works, restore it on a staging copy first, the same habit we describe in how to update WordPress without breaking your site.

Then write down what the old host is doing for you, because a migration only moves what you remember to move:

  • PHP version and the PHP settings that matter (memory limit, upload size, max execution time). Match them on the new host, or move to a newer version on purpose and test it.
  • WordPress, theme and plugin versions. Note plugins with license keys.
  • Cron jobs, both real server cron jobs and scheduled tasks in plugins such as backups or newsletters.
  • SSL certificate. Most hosts issue a free one, but it usually cannot be issued until the domain points to the new server.
  • CDN or Cloudflare. Know which one sits in front of the site and where its origin IP is set.
  • Email. This is the one people forget most often. If your mailboxes live on the old host, moving the site does not move them, and changing DNS carelessly can stop your email the same afternoon. Look at your current MX records, and decide whether the mail stays where it is (then keep those records and the old mail service) or moves too (then create the mailboxes on the new host and copy the messages over IMAP).

Lower the DNS TTL a day before

The TTL (time to live) on your DNS records tells resolvers how long they may remember the old answer. Many domains have it set to hours or even a day. Open your DNS zone, set the TTL on the A record (and the www record) to 300 seconds, and wait at least as long as the previous TTL before you switch. That way the change reaches almost everyone within minutes on switch day.

A monitor showing a domain's DNS records being edited

Three ways to copy the site

1. Let the new host do it

Many hosts offer a free migration service or their own migration plugin. You give them access to the old site, and they copy files and database for you. It is the least effort, but ask what exactly is moved (email is normally not included) and keep your own backup anyway.

2. Use a migration plugin

Plugins like Duplicator or All-in-One WP Migration package the site into an archive that you restore on the new host. They work well for small and medium sites. Free versions have limits, for example on archive size or on the upload size your new host allows, so check that your site fits before you start.

3. Copy it manually

This is the method with the fewest surprises, and the only one that works on any host:

  1. Download the whole site folder over SFTP, or compress it on the server and download the archive.
  2. Export the database, from phpMyAdmin or from the command line.
  3. Create an empty database and user on the new host, then import the export.
  4. Upload the files to the new host.
  5. Edit wp-config.php with the new database name, user, password and host.

If you have SSH access, WP-CLI makes the database steps short:

# on the old server
wp db export site-backup.sql

# on the new server, after uploading the file
wp db import site-backup.sql

If the domain changes, use search-replace the right way

If the site keeps the same domain, skip this section: the database needs no changes. If the address changes (a new domain, or http to https), WordPress has the old address stored in many places in the database, and some of it is serialized data. Serialized values record the length of each string, so a plain SQL find and replace changes the text but not the length, and the data breaks.

Use a tool that understands serialization. With WP-CLI, run a dry run first and then the real thing:

wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables --dry-run
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --all-tables

Migration plugins and the Better Search Replace plugin do the same thing from the dashboard.

Test the new copy before switching DNS

You can look at the new copy under the real domain before the world does. Your computer's hosts file overrides DNS for your machine only. Add a line with the new server's IP address and your domain (this example uses an address from the range reserved for documentation, so replace it with yours):

203.0.113.10 example.com www.example.com

The file is C:\Windows\System32\drivers\etc\hosts on Windows and /etc/hosts on macOS and Linux, and editing it needs administrator rights. Reload the site in a private window. You are now seeing the new server, while everyone else still sees the old one. the home page, a few inner pages, the contact form, the login and, on a store, the cart and checkout. Then remove the line, or you will keep seeing the new server after the DNS switch and be unable to tell what everyone else sees.

Switch DNS

There are two ways to point the domain at the new host, and they are not the same:

  • Change the A record to the new server's IP address and leave the DNS zone where it is. Your MX records and everything else stay untouched. This is the safest option, and the one to use if the DNS is at your registrar or at Cloudflare.
  • Change the nameservers to the new host's. This moves the whole DNS zone, so every record (MX, SPF, DKIM, verification records for Google or Microsoft) must be recreated in the new zone first. Skip one and the matching service stops working.

If a CDN or Cloudflare is in front, you only change the origin address there. With the low TTL, most visitors reach the new server within minutes. A few resolvers hold on to the old answer longer, which is why the old host stays up.

What to check after the switch

A person checking the same website on a phone and a laptop after moving it
  • SSL certificate. Once the domain resolves to the new server, issue the certificate there and confirm the padlock shows on every page, with no mixed-content warnings.
  • Permalinks. If inner pages return 404 errors, go to Settings > Permalinks and click Save, with no changes. It rewrites the rules for the new server.
  • Forms and email. Send a test message through every form and check it arrives. New servers sometimes need an SMTP plugin, because some hosts restrict outgoing mail.
  • Caching. Clear every layer: the caching plugin, the server cache and the CDN. Configure caching on the new host from scratch, because the settings do not travel with the site. Our post on why a website is slow covers what to look for.
  • Cron. Confirm that scheduled tasks run: scheduled posts, backups, newsletters, and WooCommerce actions on a store.
  • Search Console. If the domain stayed the same, no action is needed. If it changed, set up 301 redirects from every old URL to its new equivalent, and file a Change of Address in Search Console.

If the site shows a white screen or the message about a critical error right after the move, the cause is almost always a PHP version difference or a missing PHP extension. Our guide to the WordPress critical error shows how to read the real error.

Online stores: orders during the move

A blog can be copied while people read it. A store cannot, because orders placed on the old server while you copy, or in the minutes when some visitors still reach it, will not exist on the new one. There are two ways to handle it. The first is to put the store in maintenance mode for the short time it takes to export the database, import it on the new host and switch DNS. The second is to copy the files first and the database last, right before the switch, and freeze orders only during that final step. After the switch, check the old server for orders that came in late and enter them by hand.

Keep the old hosting for a week or two

Do not cancel the old plan on the day of the switch. Some visitors and some systems keep using the old address for a while, and if something is missing on the new server, such as a file or a mailbox, you want to be able to get it. Wait a week or two, confirm that email, forms and orders are working, take one last backup of the old site, and then cancel. For what to budget once you are settled, see how much website maintenance costs.

If you would rather not do this yourself, we handle migrations as part of our WordPress maintenance service, including the email and the redirects.

Frequently asked questions

Will my website go down during the migration?

It should not. The old site keeps answering while you copy and test the new one. The switch is a DNS change, and a low TTL makes it reach most visitors within minutes. On a store, pause orders briefly during the final copy.

Will I lose my Google rankings if I change hosts?

Not from the move itself. If the domain and the URLs stay the same, Google sees the same site on a different server. A temporary dip can happen if the new host is slower or the site errors out during the change, so test first. Rankings are at risk when the domain or URLs change, and that needs 301 redirects.

How long does a WordPress migration take?

For a typical small site, the copy takes from an hour to a few hours, plus testing. Add the day of lead time for the DNS TTL. Big media libraries, stores and email moves make it longer, so plan it for a quiet time and not for a launch week.

We can do the migration for you.

Tell us where your site is hosted and where you want it to go. We will move it, test it, and keep your email working.

Get help with your migration
Gonzalo Puig
Gonzalo Puig Co-Founder, Design and Development

Leads the agency and is part of every project, from the first call to post-launch.

LinkedIn
All articles