Networking & DNS

DNS TTL strategy for server migrations and zero-downtime changes

Choose sensible TTLs for each record type and use a lower-switch-raise plan to move a website or email to a new server with minimal downtime and no lost mail.

IntermediateDNS3 min read

TTL (time to live) tells resolvers how long they may cache a DNS answer. Getting the TTL strategy right is the difference between a server migration that switches over in minutes and one where visitors land on the old server for a day. This guide gives practical TTL values and a step-by-step plan for zero-downtime changes.

Before you start

  • Find the current TTLs: dig example.com A shows the remaining TTL next to each answer; ask your authoritative nameserver directly to see the configured value.
  • Plan at least one full old-TTL period ahead of the change.
RecordNormal TTLDuring a change
A / AAAA for websites1–4 hours300 seconds
CNAME1–4 hours300 seconds
MX1–4 hours300–600 seconds
TXT (SPF, DKIM, DMARC)1–4 hours300–600 seconds
NS1–2 daysSet at the registrar; often fixed by the TLD

Very low TTLs all the time increase query load and make you more dependent on your nameservers being up; very high TTLs make changes slow.

The lower-switch-raise plan

  1. Lower: at least one old-TTL period before the move (for example 24 hours if the TTL is 86,400), set the TTL of the records you will change to 300.
  2. Prepare: copy the site, databases and email to the new server and test it using a hosts-file entry pointing the domain to the new IP.
  3. Freeze: pause changes on the old site (or put it in maintenance mode) and do a final sync of files and databases.
  4. Switch: change the A/AAAA (and MX if moving email) records to the new server.
  5. Overlap: keep the old server running for at least a day, since some resolvers and clients ignore TTLs.
  6. Raise: once traffic has moved, set TTLs back to normal values.

Moving email without losing messages

  • Lower the MX TTL in advance, like web records.
  • Keep the old mail server accepting mail during the overlap.
  • After the switch, run a final IMAP sync (for example with imapsync) to copy messages that arrived on the old server.

Changing nameservers

Changing a domain's nameservers is slower than changing records, because NS TTLs at the TLD are often 1–2 days and you cannot lower them. Make sure the new DNS host has a complete copy of the zone before switching nameservers, so both old and new nameservers give the same answers during the transition.

What to check afterwards

  • Query several public resolvers: dig @1.1.1.1 example.com +short and dig @8.8.8.8 example.com +short.
  • Watch access logs on the old server; traffic should drop to near zero.
  • Confirm SSL certificates are issued on the new server.

FAQ: DNS TTL strategy

Why do some visitors still reach the old server after the TTL?

Some resolvers enforce minimum cache times, and browsers and operating systems cache DNS too. That's why you keep the old server running for a while.

Can I set a TTL of 0?

Technically yes, but many resolvers treat it inconsistently. 60–300 seconds is a safer minimum.

Does a low TTL slow down my website?

Slightly more lookups occur, but with typical TTLs of a few minutes the impact is small.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.