DNS & Domain Names

Lowering TTL Before a Cutover

Plan a DNS cutover step by step so traffic moves quickly: when to lower the TTL, what to verify and how to roll back.

Key takeaways

  • Lower the TTL at least one full old-TTL period before the change, and preferably with a safety margin.
  • Change the TTL and the address in two separate steps, never both at once for the first time.
  • Keep the old server serving until its logs go quiet, because some clients ignore or outlast TTLs.
  • A short TTL also makes rollback fast, so raise it again only after you trust the new setup.

Before you point a name at a new server, lower the record's time to live, wait for the old TTL to run out and only then change the address. The waiting period is the part that makes it work. A short TTL helps only after every cache has fetched a copy that carries it.

Done this way, most visitors move to the new server within minutes, and if the new server misbehaves you can send them back just as quickly. Skip the wait and you can be left with traffic split between two machines for as long as the old TTL.

What the TTL does

A TTL is a number of seconds attached to a DNS record. It tells resolvers and devices how long they may reuse an answer before asking your authoritative servers again. DNS caching and time to live covers the mechanics.

The countdown starts when a particular cache fetched the record, not when you changed it. A resolver that asked one second before your edit holds the old answer for the full TTL afterward. That worst case is what you plan around.

If the TTL is 86400 seconds, a day, then some users may reach the old server up to a day after your change. If it's 300, five minutes.

The sequence

A low-TTL cutover
1 Record the current TTL Check it at the authoritative server for every record involved. 2 Lower it Set about 300 seconds. Leave the value unchanged. 3 Wait Allow at least the old TTL, plus a margin. 4 Switch Change the record to the new address. 5 Watch Check both servers, errors and a few resolvers. 6 Restore Raise the TTL once you are satisfied. Record the current TTL Check it at the authoritative server for every record involved. 1 Lower it Set about 300 seconds. Leave the value unchanged. 2 Wait Allow at least the old TTL, plus a margin. 3 Switch Change the record to the new address. 4 Watch Check both servers, errors and a few resolvers. 5 Restore Raise the TTL once you are satisfied. 6

Each step is small. The discipline is in not compressing them.

Step 1: find every record that matters

Query your authoritative server so you see the configured TTL, not a partly counted-down cache copy.

# macOS or Linux
dig @ns1.example.com www.example.com A +noall +answer
dig @ns1.example.com www.example.com AAAA +noall +answer
dig @ns1.example.com example.com A +noall +answer
# Windows PowerShell
Resolve-DnsName www.example.com -Type A -Server ns1.example.com

Include IPv6. Forgetting the AAAA record is a common way to leave part of your audience on the old server. If www is a CNAME, check the TTL of both the alias and its target, since each is cached separately. CNAME records explains the chain.

For a mail move, list the MX records and the address records of the mail hosts they name.

Step 2: lower the TTL

Edit only the TTL. Five minutes is a sensible target for most cutovers. One minute is possible with many providers, at the cost of more queries, and some resolvers apply their own floor anyway.

Some DNS hosts offer an "automatic" TTL or fix the value for proxied records. Check what number is actually served by querying again after you save.

Step 3: wait long enough

If the old TTL was 4 hours, make the cutover no sooner than 4 hours after lowering it. In practice, lowering a day or two ahead is easiest: it costs little and absorbs surprises.

Consider this worked timeline for a move planned for Thursday at 10:00, with a current TTL of 86400.

Example cutover schedule for a one-day TTL
Tuesday 10:00 Lower the TTL to 300 seconds. Address unchanged. Wednesday 10:00 Old one-day copies have expired. Verify and test the new server. Thursday 10:00 Change the address records. Thursday 10:05 Well-behaved caches have moved. Check errors and logs. Friday Raise the TTL back and plan the old server's retirement. Tuesday 10:00 Lower the TTL to 300 seconds. Address unchanged. Wednesday 10:00 Old one-day copies have expired. Verify and test the new server. Thursday 10:00 Change the address records. Thursday 10:05 Well-behaved caches have moved. Check errors and logs. Friday Raise the TTL back and plan the old server's retirement.

The DNS TTL change planner can lay out times like these from your own values.

Step 4: test before and after

Test the new server before DNS points to it. A temporary hosts file entry, or curl --resolve, lets you reach it under the real name. Check certificates, redirects, forms, logins and anything that sends mail.

At the cutover, change the records, then confirm in this order:

  1. Every authoritative name server returns the new value.
  2. Two or three public resolvers return it, or show a small remaining TTL on the old one.
  3. The site loads from a network you didn't use for testing, such as a phone on mobile data.
  4. Logs on the new server show real visitors arriving.

Keep the old server alive

Even with a five-minute TTL, a tail of traffic continues. Some applications resolve a name once and keep the address until restarted. Long-lived connections stay put. A few resolvers stretch short TTLs.

So leave the old machine running and watch its access log. Retire it when requests fall to background noise from bots and scanners.

Think about data during this period. If both servers accept orders, comments or uploads, records end up in two places. Common approaches are to put the old site in read-only mode, to have it forward requests to the new one, or to point both at the same database. Decide before the cutover, not after.

Approach for the old server Good for Watch out for
Serve a read-only copy Sites that rarely change Visitors can't submit anything
Reverse proxy to the new server Sites that accept data Needs correct headers and certificates
Shared database Brief overlaps Network delay and version mismatches
Maintenance page Planned windows It is visible downtime

A reverse proxy on the old machine is often the cleanest answer, since every request ends up on the new system whichever address the visitor used.

Mail cutovers need extra care

Moving mail follows the same TTL logic with a few differences. Sending servers look up your MX records, then the addresses of the hosts they name, and cache both. Lower the TTL on all of them.

Before the switch, create mailboxes at the new service and add its sending authorization to your SPF record alongside the old one, so mail from either system passes during the overlap. Publish the new provider's DKIM keys ahead of time. MX records explains how senders pick a server.

After you change MX, some messages will still arrive at the old system. Keep it receiving, and check it or copy its mail across for a few days. Mail that can't be delivered is normally retried by the sending server for a while, but you shouldn't plan around that.

Weighing a weighted or staged shift

Some DNS hosts let you return different addresses to different shares of queries. You might send a small portion of lookups to the new server first, watch for errors, then increase the share.

This is useful for large sites, with two cautions. The split is approximate, because each cached answer serves many users, and one big resolver can tip the balance. And both servers must handle the same data at once for as long as the split lasts, which is the hardest part. For a small site, one clean cutover with a quick rollback is usually simpler.

Publishing two addresses under one name is a different thing. Clients may pick either, and a dead address can cause delays or failures for some of them. Don't use it as a way to ease into a migration.

A checklist for the day

  • Old values written down, with their TTLs.
  • New server tested under the real hostname.
  • Certificates installed and valid for every name.
  • Low TTL confirmed at every authoritative server.
  • Someone assigned to watch errors and logs.
  • A clear condition for rolling back, agreed before you start.
  • A plan for data created during the overlap.

Pick a quiet time for your audience, and avoid starting right before you're unavailable. Problems that depend on caching often appear an hour or two later.

Rolling back

If the new server fails, set the record back to the old address. Because the TTL is still low, recovery takes minutes. This is the strongest reason not to raise the TTL immediately after a successful-looking switch.

Write down the old values before you change anything. During an incident, nobody wants to reconstruct an address from memory.

A rollback only works if the old server is still intact and its data is still usable. If users have been writing data to the new system, plan how that data would travel back.

What a low TTL can't speed up

Several changes have their own clocks.

  • Name server changes. The delegation lives in the parent zone and uses the registry's TTL. See migrating DNS without downtime.
  • DS records. DNSSEC changes involve the parent zone too.
  • Negative answers. A cached "does not exist" lasts according to the zone's SOA settings, so create new names ahead of time.
  • Web caches. A content delivery network or browser may serve old pages after DNS has moved. See cache-control headers.

After the cutover

When you're confident, restore TTLs. Many sites use anywhere from several minutes to an hour for web records and longer for records that rarely change. If you rely on DNS for failover, keep those particular records short.

Then clean up. Remove test entries from hosts files, delete records that point to the retired server and release its address only after nothing references it. A forgotten record pointing at an address or service you no longer control creates a security risk, described in dangling DNS and subdomain takeover.

Common questions

Do I need to do this for a brand new record?

No. Nothing holds an old value for a name that never existed, though a resolver might hold a negative answer if someone looked it up earlier.

What if I can't wait for the old TTL?

You can change the record now and keep both servers serving correct content, ideally with the old one proxying to the new. Users move over as their caches expire.

Does lowering the TTL cause downtime?

No. The record's value is unchanged, so every answer remains correct. The only effect is that caches check back more often.

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 DNS & Domain Names →

Latest news on this topic