Everyone Forgets DNS TTL.

Changing DNS settings can be scary, frustrating, and painful, there's no doubt about that. But one thing I continuously see around the dev community is a misunderstanding of DNS change propagation times and the impacts DNS records' TTL setting can have. DNS doesn't have to be painful! If you set it up correctly, updates can propagate across the web in seconds, not hours!

If you want to read the long version, I suggest reading this guide which was written by Netlify (thanks, Luke!). But here's the short version: if you a) know that you're going to change your DNS records 1 or 2 days ahead of time, or b) want to change them quickly but are willing to wait 1 or 2 days, then your DNS changes can be very, very simple.

Step 1: Change current TTL

Log into whichever service is running your nameservers (in my case NameCheap is my registrar but I use Netlify's Nameservers) and change the target DNS record's TTL value to 5 seconds. If your provider won't go as low as 5, choose the smallest option.

Step 2: Wait

Since DNS is a distributed, cached system, we need to wait for all of the DNS servers that may be caching your record to flush out and cache the new one (which has a very short TTL). You likely won't want to wait any less that 24 hours, but if you can make 48 hours work, I'd recommend that.

Step 3: Change the Record

Now that we've waited for global DNS caches to flush out old records with their long TTLs, we can be sure that once we change the target record, it'll distribute out to all consumers within a minute or two. Often in seconds.

If you're certain that you won't need to change the record again, you can set the new record's TTL back to 'normal' (most providers use 3600 seconds as a default), but beware that once you change back to 3600 (or any higher time), you'll have to restart this 1-2 day waiting the next time you want to make a DNS change for that record. If you anticipate possible changes in the near future, just leave the TTL for the newly changed record at 5. Once your DNS options stabilize, you can go back in and change the record back to 3600.

Photo by @comparefibre on Unsplash


Want to stay in the loop? One email per week.

No spam. No data selling. Never.


Latest Blogposts

I Got Married!

Starting a life-long journey together :)

January 3 2021

Configuring Environment Variables for All Netlify Environments

Correctly setup ENV vars for local, deploy-preview, branch-deploy, and production

December 30 2020