host.onl

Guide

How to migrate a site to a new host

The order of work for moving a website to a new host without downtime or lost email.

Moving a website to a new host is mostly a matter of doing a few steps in the right order. Done that way, visitors see no downtime and no email is lost. The steps below apply to most sites; the WordPress notes apply if your site runs on it.

Before you start

  • Keep the old hosting running until the move is finished and checked. Do not cancel first.
  • Find out where your domain and DNS are managed. They may be with the old host, a registrar or a separate DNS service. You will change DNS records near the end.
  • List what the old account does besides the website: email mailboxes, scheduled tasks, redirects, subdomains, SSL certificates. Each one needs a new home.
  • Lower the DNS time-to-live on your site's records to five minutes, a day or two ahead. The switch will then take effect quickly.

1. Take a full copy

You need two things: the site's files and its database.

  • Files: download the whole web directory by SFTP, or use the host's backup tool to make an archive.
  • Database: export it as an SQL file with the host's database tool or from the command line.

For WordPress, the files include wp-content (themes, plugins and uploads) and wp-config.php, and the database holds posts, pages and settings. A backup or migration plugin can package both. Many managed hosts also offer a migration tool or will do the move for you; check what your new plan includes.

Store a second copy of the backup somewhere other than either host.

2. Set up the new hosting

  • Create the site or server on the new host.
  • Create an empty database and a database user, and note the name, user, password and host.
  • Match the software versions you were running, especially PHP, so the site behaves the same.

3. Restore the copy

  • Upload the files to the new web directory.
  • Import the SQL file into the new database.
  • Update the site's configuration with the new database details. In WordPress that is wp-config.php.

4. Test before anyone sees it

The domain still points at the old host, so you need another way to reach the new one. Use the temporary address or staging domain the new host provides, or add a line to your own computer's hosts file that maps your domain to the new server's IP address.

Check, at least:

  • the home page and a few inner pages, including images;
  • logging in to the admin area;
  • forms, search and, for a shop, a test order;
  • that HTTPS works, once the certificate is issued.

Fix anything that is wrong now. Nothing has changed for your visitors yet.

5. Pause changes, then take the final copy

If the site changes often (orders, comments, new posts), anything added to the old site after your backup will be missing from the new one. Choose a quiet time, stop making changes or put the old site in maintenance mode, and repeat the database export and import so the new copy is current.

6. Point the domain at the new host

Change the DNS records for the site to the new host's address, usually the A record and, if used, the AAAA record or a CNAME. If the new host asks you to change nameservers instead, recreate every existing record there first, including the mail records, so nothing else breaks.

With a short time-to-live most visitors reach the new host within minutes. For a day or so some will still reach the old one, which is why it stays running.

7. Email

If your mailboxes are with the old host, they do not move when the website does.

  • If mail will stay where it is, leave the MX records alone when you change the site's records.
  • If mail is moving too, create the mailboxes at the new provider, copy the existing mail across, and only then change the MX records.

Losing mail is the most common migration mistake, and it happens when nameservers are switched without copying the mail records.

8. After the switch

  • Check the live site again on its real address.
  • Confirm the SSL certificate is valid and that the plain HTTP address redirects to HTTPS.
  • Set up backups and scheduled tasks on the new host.
  • Raise the DNS time-to-live back to its normal value.
  • Keep the old account for a week or two, then download a last backup and cancel it before its next renewal date.

How long it takes

A small site can be moved in an afternoon. Allow a few days in total so there is time to test without hurrying, and start well before the old plan's renewal date. The guide to introductory and renewal pricing explains why that date matters.

More guides

  • How to choose a hosting plan

    A step-by-step way to pick a hosting plan from what your site needs, not from the headline price.

  • Introductory versus renewal pricing

    How first-term discounts work, where the renewal price is stated, and how to work out what a plan costs over three years.

  • Compare hosting plans

    Every listed plan in one table, with filters for type, price, memory and storage.