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 Ashows 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.
Recommended TTLs
| Record | Normal TTL | During a change |
|---|---|---|
| A / AAAA for websites | 1–4 hours | 300 seconds |
| CNAME | 1–4 hours | 300 seconds |
| MX | 1–4 hours | 300–600 seconds |
| TXT (SPF, DKIM, DMARC) | 1–4 hours | 300–600 seconds |
| NS | 1–2 days | Set 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
- 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.
- 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.
- Freeze: pause changes on the old site (or put it in maintenance mode) and do a final sync of files and databases.
- Switch: change the A/AAAA (and MX if moving email) records to the new server.
- Overlap: keep the old server running for at least a day, since some resolvers and clients ignore TTLs.
- 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 +shortanddig @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.
