DEV Community

overnight.host
overnight.host

Posted on

Migrating a website to a new host with near-zero downtime

The scary part of moving hosts is the gap where the site is half here and half there. Sequence it right and visitors never notice.

1. Build the new home first, behind the scenes

Set everything up on the new server while the old one keeps serving. Copy the files and the database, get the app running, and test it by hitting the new IP directly (a hosts-file entry on your laptop pointing the domain at the new IP lets you browse the real site there before anyone else does).

2. Lower your DNS TTL ahead of time

A day before the move, drop the TTL on the relevant records to 300 seconds. Now when you flip, caches expire in minutes instead of a day or two. Do this early, because the old long TTL has to expire first.

3. Freeze, sync the delta, flip

Pick a quiet window. Put the old site in read-only or maintenance mode briefly, sync the last database changes and any new uploads to the new box, then change the DNS A record to the new IP. Because the TTL is low, resolvers pick it up fast.

4. Both servers serve during the overlap

For a short while, some visitors still hit the old IP and some hit the new one. This is why you went read-only for the cutover: so no writes land on the old box that the new one misses. Once traffic has clearly moved (check your new server's access logs), you can lift maintenance mode on the new host.

5. Re-issue TLS and confirm

Make sure the certificate on the new host covers the domain, then walk the site: forms, logins, checkout, the lot. Leave the old server up for a few days as a fallback before you tear it down.

The one that bites people

Email and DNS often live with the old host. Before you cancel anything, move your MX records and any other records, not just the A record, or you will silently lose mail.


overnight.host does free migrations as part of onboarding for exactly this reason: the sequencing is routine for us and nerve-wracking to do alone for the first time.

Top comments (0)