Websites & Hosting

How to Migrate a Website to a New Host

Move your site with little or no downtime: inventory, copy, test on the new server, switch DNS and keep a way back.

Key takeaways

  • Inventory everything the old host does for you, including email, scheduled tasks, redirects and DNS.
  • Copy files and database, then test on the new server before changing public DNS.
  • Lower the DNS time to live ahead of the switch so that the change takes effect quickly.
  • Freeze or reconcile new data such as orders and comments during the cutover.
  • Keep the old account active until traffic, mail and backups are confirmed on the new one.

To move a website without losing visitors or data, build a complete copy on the new host while the old one keeps serving, test that copy before the public can see it, then point DNS at it and leave the old server running for a while. Done in that order, most small sites can move with little or no noticeable downtime.

Trouble almost always comes from things nobody listed: a scheduled job, a mailbox, a redirect or an order that arrived mid-move. So the work starts with an inventory.

The whole move at a glance

A migration in order
1 Inventory List files, databases, mail, jobs, redirects and DNS records. 2 Lower TTL Shorten DNS caching a few days before the switch. 3 Copy Transfer files and import the database on the new host. 4 Test privately Check the new copy before DNS points to it. 5 Final sync Pause changes and copy anything new. 6 Switch DNS Point the records at the new server. 7 Watch, then retire Monitor both and cancel the old plan only later. Inventory List files, databases, mail, jobs, redirects and DNS records. 1 Lower TTL Shorten DNS caching a few days before the switch. 2 Copy Transfer files and import the database on the new host. 3 Test privately Check the new copy before DNS points to it. 4 Final sync Pause changes and copy anything new. 5 Switch DNS Point the records at the new server. 6 Watch, then retire Monitor both and cancel the old plan only later. 7

Step 1: Take inventory

Walk through the old control panel and write down:

  • all domains and subdomains served,
  • site files, including uploads outside the main folder,
  • databases, database users and character sets,
  • language versions and required extensions,
  • scheduled tasks (cron jobs),
  • server rules: redirects, password-protected folders, custom headers,
  • certificates and how they renew,
  • email accounts, forwarders and filters, and
  • every DNS record, if the host also runs your DNS.

Two items deserve emphasis. If the old host provides your email or DNS, cancelling the plan can silently take those down. Decide where each will live before you move anything.

Check the new host supports what you need, and avoid changing too much at once. Upgrading the language version, redesigning and switching hosts in the same weekend makes any fault much harder to trace.

Step 2: Lower the TTL

DNS answers are cached for the number of seconds in their time to live. A few days ahead, reduce the TTL on the records you will change to something like 300 seconds. The reduction itself only takes full effect after the old, longer TTL has expired. Lowering TTL before a cutover covers the timing, and the DNS TTL change planner helps lay it out.

Step 3: Back up and copy

Take a full backup of files and database and keep a copy on your own computer. If something goes wrong, this is your way back.

With command-line access on both servers, rsync copies files efficiently and can be rerun to pick up changes. Run from the new server:

rsync -av [email protected]:/var/www/site/ /var/www/site/

For a MySQL or MariaDB database, export on the old server and import on the new one:

mysqldump -u dbuser -p --single-transaction sitedb > sitedb.sql
mysql -u dbuser -p sitedb < sitedb.sql

Create the empty database and user on the new host first. --single-transaction gives a consistent snapshot for InnoDB tables without blocking writes. Dumps contain your users' data, so keep them out of any web-accessible folder and delete spare copies when you finish.

Without shell access, use SFTP for files and the control panel's database export and import. Some hosts offer a migration tool or will do the transfer; ask what it leaves out.

Then update configuration files on the new server: database name, user, password, file paths and any API settings.

Step 4: Test before anyone sees it

You can make your own computer treat the domain as living on the new server while everyone else still reaches the old one.

For a single command-line check:

curl --resolve www.example.com:443:198.51.100.25 -I https://www.example.com/

For browser testing, add a line to your hosts file:

198.51.100.25  example.com www.example.com

The file is /etc/hosts on macOS and Linux and C:\Windows\System32\drivers\etc\hosts on Windows, and editing it needs administrator rights. Remove the line afterward.

The new server may not have a valid certificate for the name yet. Options include copying the existing certificate and key securely, obtaining one through a DNS-based validation, or testing with warnings on your own machine and arranging the certificate promptly at cutover.

Check these on the copy:

  1. Home page, several inner pages and a missing page.
  2. Sign-in, search, forms and checkout in test mode.
  3. File uploads, which exposes permission problems.
  4. Outgoing email from the site.
  5. Images and styles, looking for hard-coded old paths or addresses.
  6. Error logs, even if pages look fine.

Be careful that the copy does not act like the live site. A cloned store with active scheduled jobs could send customers duplicate emails or renewal charges. Disable those until cutover.

Step 5: Freeze and sync

Anything written to the old site after your copy will be missing from the new one. For a brochure site that is nothing. For a store, forum or busy blog it is orders, posts and comments.

The usual answer is a short maintenance window at a quiet hour: put the old site into maintenance mode (returning status 503), export the database once more, import it, rerun the file sync and then switch DNS.

Step 6: Switch DNS

Change the A and AAAA records, or the CNAME, to the new addresses. Update both IPv4 and IPv6, or remove an AAAA record that you cannot serve. If you are moving DNS hosting too, recreate every record at the new provider before changing name servers, as described in migrating DNS without downtime.

What may still point at the old server after the switch
Cached DNS answers Resolvers keep the old address until the TTL runs out. A forgotten AAAA record IPv6 visitors keep arriving at the old machine. Hard-coded addresses Scripts, apps or settings that use the old IP. Outside integrations Webhooks or allow lists that name the old server. Cached DNS answers Resolvers keep the old address until the TTL runs out. A forgotten AAAA record IPv6 visitors keep arriving at the old machine. Hard-coded addresses Scripts, apps or settings that use the old IP. Outside integrations Webhooks or allow lists that name the old server.

For a while, some visitors will reach each server. If both accept writes, data will split. Leaving the old site in maintenance mode, or proxying its requests to the new one, prevents that.

Step 7: Verify and watch

Confirm that public lookups return the new address, then browse the site normally with the hosts file line removed. Issue or renew the certificate, re-enable scheduled jobs on the new server only and check that mail still flows both ways.

Watch error logs and not-found requests for several days. If the web addresses of pages changed, add permanent redirects from each old URL to its closest new one. A host move that keeps the same URLs generally has little effect on search listings; changing URLs at the same time is what needs care.

Moving email along with the site

If mailboxes live on the old host, treat them as a second migration with its own plan. Create every mailbox, alias and forwarder at the new mail service first. Copy existing messages using an IMAP migration tool or the new provider's import feature, then change the MX records. Run one more copy afterward to collect anything delivered to the old boxes while DNS caches caught up.

The domain's mail authentication records need attention at the same time. SPF must list the services that now send for you, DKIM needs the new provider's key and any DMARC record should be carried over. Mail from the website itself counts too. A new web server sending directly, without being listed or signed, is a common reason that order confirmations start landing in spam.

Tell users what will change for them, such as server names and passwords in their mail apps, before the day of the switch.

Notes for platform-specific moves

Content management systems. If the site address stays the same, little in the database needs editing. If it changes, use the system's own tool for replacing addresses, since some stored settings break when edited as plain text.

Website builders. Many do not export a working site. You may have to rebuild the design and move content by hand or by export file, which turns a migration into a redesign. Collect the list of old page addresses first so that you can redirect them.

Static sites. These are the easiest to move: publish the same files to the new platform, test at its temporary address, recreate redirects and headers, then switch DNS.

Having a way back

Decide beforehand what failure would make you revert. Rolling back is simple while the old server is intact: point DNS back. It gets harder once new data has accumulated on the new server, so make that call early.

Keep the old account for at least a week or two, longer for sites with monthly tasks. Before cancelling, download a final backup, confirm the new host's backups are running and restore one as a test. Then delete the data on the old account according to the provider's process, and remove any DNS records that still refer to it.

Write the revert steps down with the old record values next to them, so that nobody has to reconstruct them under pressure.

Frequent snags

White page or database error. Check connection settings, language version and missing extensions.

Uploads fail. File ownership or permissions differ on the new system. Avoid fixing it by making everything writable by everyone.

Strange characters. The database was imported with a different character set.

Redirect loop. HTTPS rules in the application and at a proxy or CDN disagree.

Mail vanished. MX records were not recreated, or mailboxes lived on the old host and were never moved.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Websites & Hosting →

Latest news on this topic