How to Move a WordPress Site to a New Host: Migration Workflow

A rack of electronic equipment in a dark room

Moving a WordPress site to a new host means copying the files and the database, connecting them on the new server and switching the domain over, ideally without visitors noticing. The method below keeps the old site running until the new one is verified, so there is always a way back.

Before you start

  • Access to the old hosting account and the new one.
  • Access to the DNS settings of the domain.
  • A note of where email for the domain is hosted. If mailboxes live on the old host, they must be moved or recreated separately. This is the most commonly forgotten part of a migration.
  • A quiet period. Avoid moving during a sale or campaign.

Step 1: Prepare the old site

  1. Update WordPress, themes and plugins, and confirm the site works.
  2. Take a full backup of files and database and download a copy. See How to Create a Basic Website Backup and Test a Restore.
  3. Note the PHP version in use.
  4. A day before the move, lower the TTL of the domain’s A record to about 300 seconds, so the switch takes effect quickly.

Step 2: Prepare the new host

  1. Add the domain to the new hosting account.
  2. Select the same or a newer supported PHP version.
  3. Create an empty database and a database user with a strong password, unless your migration tool does this for you.

Step 3: Choose a migration method

  • The new host’s migration service. Many hosts move a site for you, free or for a fee. If offered, this is usually the easiest route.
  • A migration plugin. You install the plugin on the old site, create a package or connect to the new site, and it transfers everything. Suitable for most small and medium sites.
  • Manual migration. You copy files and database yourself. It works everywhere and is worth understanding even if you use a tool.

Step 4: Manual migration in detail

  1. Export the database from the old host using its database tool. Save the .sql file.
  2. Download the files: the whole WordPress folder, including wp-content and wp-config.php, over SFTP or as a compressed archive from the file manager.
  3. Upload the files to the web root on the new host.
  4. Import the database into the empty database on the new host.
  5. Edit wp-config.php on the new host so the database name, user, password and host match the new database.

If the domain stays the same, no address changes are needed in the database. If the address changes, use a proper search-and-replace tool that understands WordPress data, such as WP-CLI. Do not edit the .sql file with a text editor, because that corrupts serialized settings.

Step 5: Test before switching the domain

The domain still points to the old host, so you need another way to view the new copy.

  • Use the temporary address or preview feature the new host provides, or
  • Edit the hosts file on your own computer so that only your machine sees the domain at the new server’s IP address.

Then check:

  1. The homepage and several inner pages load with images and correct design.
  2. You can log in.
  3. Forms send, and shop pages and checkout work in test mode.
  4. Permalinks work. If inner pages show errors, open Settings, Permalinks and click Save.
  5. No errors appear in Tools, Site Health.

Step 6: Handle changing content

Anything created on the old site after you copied it will be missing on the new one. For a brochure site, simply avoid editing during the move. For a shop or busy site, either put the old site into maintenance mode shortly before the final copy, or run the copy again immediately before switching DNS.

Step 7: Switch DNS

  1. Change the A record, and the AAAA record if used, to the new server’s address. Or change the nameservers if the new host manages your DNS, after recreating all records, including email records, in the new zone.
  2. Leave MX records as they are unless email is moving too.
  3. Wait for the change to take effect. With a low TTL this usually takes minutes to an hour.

How to Connect a Custom Domain to Web Hosting covers this step in detail.

Step 8: Finish on the new host

  1. Issue the SSL certificate once the domain points to the new server, and confirm https works without warnings.
  2. Remove any hosts file entry you added and test again from a different network.
  3. Send a test through each form and place a test order.
  4. Check that scheduled tasks and email delivery work. Transactional email often needs SMTP settings on the new host.
  5. Set up backups and caching on the new host.
  6. Raise the TTL back to its normal value.

Step 9: Keep the old site for a while

Do not cancel the old hosting straight away. Keep it for one to two weeks, in case a problem appears or some visitors are still being sent there. Then take a final backup and close the account.

Common mistakes

  • Cancelling the old host before the new site is verified.
  • Forgetting that mailboxes were on the old host.
  • Editing the database export in a text editor.
  • Moving while orders or comments are still arriving on the old site.
  • No SSL certificate on the new server at the moment DNS switches.
  • Leaving the new site set to discourage search engines.

Next step

Use the Website Migration Checklist to tick off each stage, and read Shared Hosting, Managed Hosting and VPS if you are still choosing where to move.