cPanelOps · Hosting guides for site operators
cPanelOpsv2.2.0
Plain-English cPanel help from the team behind FirstResponderHost
26 guides live
CpanelOps / PageOps

Home › Guides

Reliability

Moving a site to a new host with almost no downtime

The order of steps that keeps the site and the email working throughout: copy, test on the new server, switch DNS, then wait before cancelling.

Moving hosts has a reputation for causing outages and lost mail. Nearly all of that comes from doing the steps in the wrong order, usually by switching the domain before the new server is ready, or cancelling the old account the same day. Done in the right order, visitors do not notice anything.

The idea

For a period, the site exists in two places. You build and test the copy on the new host while the old one keeps serving visitors. Only when the copy is proven do you repoint the domain, and you keep the old account running until the switch has fully taken hold.

A few days before: lower the TTL

In your DNS, lower the time-to-live on the domain's A record and on www to 300 seconds. This makes the eventual switch take effect in minutes instead of hours. It needs to be done at least a day ahead, because the old, longer value has to expire first. The DNS guide explains TTL.

Step 1: copy everything

If both hosts run cPanel, the simplest route is a full account backup from the old host, which the new host restores for you. Most hosts offer this as a free migration; ask before doing it by hand.

By hand, you need three things:

  • The files: everything in the site's folder.
  • The database: exported from phpMyAdmin on the old host and imported on the new, into a new database with a new user.
  • The configuration: update the site's configuration file with the new database details.

Do not forget the things outside the site's folder: scheduled jobs, email accounts and forwarders, redirects, and any custom PHP settings.

Step 2: test the copy before anyone else can see it

The domain still points at the old server, so how do you look at the new one? Tell your own computer to use the new server for that name, by adding a line to its hosts file:

203.0.113.10   yourdomain.com www.yourdomain.com

Use the new server's address in place of the example. The file is /etc/hosts on Mac and Linux, and C:\Windows\System32\drivers\etc\hosts on Windows; it needs administrator rights to edit. Your browser now loads the new copy under the real domain name while everyone else still sees the old one.

Check everything: pages, images, sign-in, forms, anything that sends email. Expect a certificate warning at this stage, since the new server cannot get a certificate for a domain that does not yet point at it. Remove the line when you finish testing.

Step 3: freeze changes, then make a final sync

Anything added to the old site after your copy, such as a new post, comment or order, is not on the new server. Just before the switch, stop making changes on the old site, export the database once more, and import it over the copy. For a site that changes rarely, this is a formality. For a busy one, pick a quiet hour.

Step 4: switch the DNS

Change the A records for the domain and www to the new server's address. If you are also moving nameservers to the new host, change them at the registrar instead; make sure the new host's zone already contains every record you rely on, including email and verification records, before you do.

With the TTL lowered, most visitors arrive at the new server within minutes. Then open SSL/TLS Status on the new host and run AutoSSL, so the certificate is issued as soon as the name resolves there.

Step 5: email

If mailboxes live on the hosting account, they move too:

  1. Create the same mailboxes on the new host before the switch, with the same passwords if possible.
  2. After the switch, new mail arrives at the new server. Old mail is still on the old one.
  3. Copy the old messages across. A mail program connected to both accounts can drag folders from one to the other, and many hosts will run a server-to-server copy for you.

If your email is with a separate provider, leave the MX records exactly as they are and it is unaffected.

Step 6: keep the old account for a week or two

Some networks hold on to old DNS answers longer than they should. For a few days a trickle of visitors and mail will still reach the old server. Leave it running. Check its mailboxes once more before you cancel, then take a final full backup and close the account.

Afterwards

  • Raise the TTL back to a normal value such as 14400.
  • Recreate scheduled jobs and confirm each one runs.
  • Confirm the PHP version and its settings match what the site needs.
  • Send a test email from the site and check that SPF and DKIM pass from the new server. The email guide shows how.
  • Set up backups on the new host. The schedule from the old one did not come with you.

Common questions

Will moving hosts hurt my search ranking?

Not if the addresses stay the same and the site stays up. Search engines do not care which company hosts a page.

How long does the whole thing take?

For a small site, an hour or two of work spread over a few days: lower the TTL, copy and test, switch, then wait before cancelling.

Can I change the domain name at the same time?

Do one at a time. Move hosts first with everything else unchanged, let it settle, then change the domain with proper redirects.

Spotted a mistake, or a step that has changed?

cPanel's screens differ a little between versions and hosts. Tell us at info@firstresponderhost.com and we will correct the guide.

More guides