How to flush the CoreDNS cache on a Kubernetes cluster
Codemia Knowledge Hub ·
There is no "flush cache" command for CoreDNS in kubectl. Each CoreDNS pod keeps its own in-memory cache, so the practical way to clear it is to restart the pods with kubectl -n kube-system rollout restart deployment/coredns. The new pods start with empty caches.
Why there is no single cache to flush
CoreDNS caches DNS answers in memory so repeated lookups are fast and upstream resolvers do less work. During debugging, that cache can hide recent changes until the cached records expire.
CoreDNS usually runs as a Deployment in the kube-system namespace, and each pod has its own cache:
- with two CoreDNS replicas, each holds its own cached answers
- clearing one pod does not clear the others
- restarting the pods is the normal way to clear cached entries
Restart the CoreDNS Deployment
This is the simplest and safest path because Kubernetes handles the pod replacement. Restarting only one pod in a multi-replica setup can leave stale answers on the others.
If you are not sure what the DNS component is called in your cluster, look first:
Some environments use different names, and managed clusters may add extra DNS components around CoreDNS.
Check the cache TTL in the Corefile
Recurring stale answers are often a TTL problem. The cache plugin is configured in the CoreDNS Corefile, which typically lives in a ConfigMap:
A common configuration contains a line such as:
That value controls how long answers may stay cached. If the cluster keeps serving stale answers longer than expected, tuning this duration is better than restarting DNS every time.
Test DNS from inside the cluster
Test before and after the restart from inside the cluster, so you check the same network path your workloads use:
For an external lookup:
Testing from a workstation outside the cluster bypasses the in-cluster DNS path entirely.
When stale answers survive a restart
Then the CoreDNS cache is probably not the cause. Other layers can hold DNS state:
- the application runtime may cache lookups
- a node-local DNS layer may still hold old answers
- the upstream DNS server may still serve the old record
- the Kubernetes Service or Endpoints data may not have updated yet
Restarting CoreDNS clears CoreDNS memory, not every cache in the system.
Restarting CoreDNS in production
A restart is usually low risk in a healthy cluster, but it is still a control-plane networking action. Do it deliberately, watch the rollout, and confirm the pods are ready before assuming DNS is stable. If stale answers keep coming back, fix TTLs, upstream DNS or application caching instead of making restarts routine.
Related reading
- For a helm chart, what versions are available?
- Forbidden to access Kubernetes API Server
- Force moving a Pod from one worker Node to another
- force refresh of docker image when updated in registry / kubernetes
- For parallel algorithm with N threads, can performance gain be more than N?
- force browsers to get latest js and css files in asp.net application
- Force SSL on Amazon S3
- Format a date using the new date time API
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.