How to Move a Website to a New Host Without Downtime

Moving a site to a new host doesn't have to involve a maintenance page. Downtime during a move nearly always comes from doing things in the wrong order: changing DNS before the new server is proven, shutting the old one down too early, or discovering a missing certificate or mail record after visitors arrive. Run both servers side by side, test the new one privately, and make the DNS change the last and least dramatic step.

Step 1: Write down everything the domain does

Before copying a single file, record what the domain currently points where. Export the full DNS zone from your current provider if it allows it, and check the records one by one with our DNS lookup tool. Pay attention to:

  • A and AAAA records for the bare domain and www. Forgetting the AAAA is a classic cause of "it works for me but not for them".
  • MX records. If your old host also handles your email, moving the website can quietly break mail. Decide now whether mail is moving too, and if not, make sure the MX and its target records stay exactly as they are.
  • TXT records for SPF, DKIM, DMARC and domain verification (Google, Microsoft and others). Losing these breaks email authentication and verified services.
  • Subdomains like shop., api., mail. or cdn. that point elsewhere.

Also note what the server does that isn't in DNS: cron jobs, redirect rules in .htaccess or the web server config, environment variables, and the PHP, Node or database versions the site expects.

Step 2: Lower the TTL now, days before the move

The TTL on your current records controls how long resolvers will keep sending visitors to the old server after you switch. Lower it to 300 seconds on the records you'll change, then wait at least one full old TTL before moving anything. If the current TTL is a day, do this at least a day ahead. The reasoning and the traps are in DNS TTL explained.

Step 3: Build the new server and copy the site

Set up the new host to match the old environment, then copy the files. rsync is ideal because you can rerun it later to pick up only what changed:

rsync -avz [email protected]:/var/www/example/ /var/www/example/

The trailing slashes matter: they copy the directory's contents rather than creating a nested folder.

For a MySQL or MariaDB database, a consistent dump without locking InnoDB tables looks like this:

mysqldump --single-transaction --routines --triggers -u dbuser -p exampledb > exampledb.sql
mysql -u dbuser -p exampledb < exampledb.sql

Run the dump on the old server and the import on the new one. Then update the site's configuration with the new database credentials and hostnames.

Step 4: Test the new server before DNS knows about it

This is the step that removes the risk. You can make your own computer visit the new server under the real domain name without changing public DNS.

With the hosts file. Add a line mapping the domain to the new server's IP (here 203.0.113.10):

203.0.113.10  example.com www.example.com

The file is /etc/hosts on macOS and Linux and C:\Windows\System32\drivers\etc\hosts on Windows. Browse the site normally, log in, submit a form, check images and admin pages. Remove the line when you're done, or you'll be confused later.

With curl. For quick checks without editing anything, --resolve pins a name to an address for one request:

curl -I --resolve example.com:443:203.0.113.10 https://example.com/

Look for a 200 (or your expected redirect) and the right headers. Test the www version and a few deep URLs too.

Step 5: Have HTTPS ready before the switch

If the new server has no valid certificate when visitors arrive, they get a browser warning, which counts as downtime. There's a chicken-and-egg problem here: Let's Encrypt's default HTTP-01 challenge fetches a file from your domain on port 80, so it only succeeds once the domain points at the new server.

Three ways round it:

  • Use the DNS-01 challenge. You prove control by publishing a TXT record at _acme-challenge.example.com, which works regardless of where the A record points. Most ACME clients support it through your DNS provider's API.
  • Redirect the challenge. Let's Encrypt follows HTTP redirects (up to 10, to ports 80 or 443 only), so the old server can redirect /.well-known/acme-challenge/ requests to the new one.
  • Copy the existing certificate and key from the old server, if you have them, and renew on the new server after cutover.

Once installed, check it through the hosts-file trick, then after the move confirm it with our SSL checker, which shows the chain and expiry date.

Step 6: Freeze, sync and switch

For a static site you can switch whenever you like. For anything with a database (a shop, a CMS with comments, a membership site) you need a short content freeze, or orders placed on the old server will be lost.

  1. Put the old site into a read-only or maintenance mode for admin changes, or pause new orders briefly.
  2. Rerun rsync and take a fresh database dump and import. This final sync is fast because only changes move.
  3. Change the A and AAAA records to the new server's addresses.
  4. Watch the change spread with our DNS propagation checker. With a 300-second TTL in place, most resolvers follow within minutes.
  5. Confirm the site responds correctly from different countries with the global HTTP check, not just from your own desk.

If you're also changing DNS provider (moving name servers, not just records), do that as a separate step, days before or after. Recreate the entire zone at the new provider first and compare it record by record. If DNSSEC is enabled, the DS record at your registrar must match the new provider's keys, or validating resolvers will fail to resolve the domain at all. The safe route is to remove the DS record, wait for it to expire, move, and then re-enable DNSSEC at the new provider.

Step 7: Don't switch off the old server yet

Some resolvers ignore low TTLs, and some visitors will reach the old server for a while. Leave it running for a few days at least. A useful trick is to have the old server proxy or redirect traffic to the new one, so anyone still arriving there lands on current content.

Before cancelling, check the old server's access logs. When real traffic has dwindled to bots, and email is confirmed working on the new setup, you're done. Our post on DNS propagation covers why a straggler resolver or two is normal.

Frequently Asked Questions

How long should the whole migration take?

The work itself can be a few hours. The waiting sets the schedule: lower the TTL at least one full old TTL beforehand, and keep the old server around for a few days after. Plan for about a week from start to finish.

Will moving hosts hurt my search rankings?

A clean move with the same URLs and content, and no period of errors, is a change search engines handle routinely. Rankings suffer when pages return errors, URLs change without redirects, or the site is unreachable during the switch.

Do I need to change registrars to move hosts?

No. The registrar, the DNS provider and the web host are three separate roles, even when one company sells all three. You can move the site and leave the domain registration exactly where it is.

What if something goes wrong after the switch?

Point the records back at the old server. Because you kept the TTL low and the old server running, a rollback takes effect as quickly as the original change.

Was this useful?
Share

Related reading

0 comments

No comments yet. Be the first.

Leave a comment

Comments are reviewed before they appear. Your email is optional, is never published, and is only used if we need to reply.

« Back to Blog