DNS "Bad Key" Error: What It Means and How to Fix It
In this article
A DNS "bad key" error almost always means DNSSEC validation is failing: the resolver asked for a DNSKEY record and the key it got back doesn't match or is unusable. The fastest fix on your side is to flush the DNS cache and switch to a different resolver; if you run the domain, the fix is correcting the DNSSEC keys or DS records at your DNS provider.
Time 15 min · Steps 6 · Level Medium
How to Clear the Bad Key Error on Your Device
- Flush the local DNS cache. On Windows, open Command Prompt and run ipconfig /flushdns. On macOS, run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder in Terminal. On Linux with systemd, run sudo resolvectl flush-caches. A cached bad key keeps failing even after the real record is fixed.
- Restart your router. Unplug it, wait about 30 seconds, plug it back in. Many routers cache DNS results and DNSSEC validation state, and a restart clears both.
- Switch to a different DNS resolver. Set your device or router to use a public resolver such as Google Public DNS or Cloudflare's 1.1.1.1. If the error disappears, the problem was the old resolver's DNSSEC validation, not the site itself.
- Test from another network. Load the site over mobile data instead of Wi-Fi. If it works there, the fault is in your network's resolver; if it fails everywhere, the domain's DNSSEC records are broken.
- Check the domain's status. Use a DNS lookup tool to query the domain's DNSKEY and DS records. A missing DNSKEY while a DS record still exists at the parent zone is the classic cause of a bad key failure.
- Report or wait. If the domain's records are broken, only the domain owner can fix them. Errors like this are usually repaired within hours once the operator notices.
What the Symptom Tells You About the Cause
| Symptom | Likely cause | Fix |
|---|---|---|
| One site fails, others load; browser shows DNS error or SERVFAIL | Broken DNSSEC on that domain (missing or mismatched DNSKEY) | Nothing on your device; wait for the owner to fix it, or confirm with an online DNSSEC checker |
| Many sites fail the same way | Your resolver's DNSSEC validation is broken or its cache is stale | Flush cache, restart router, switch resolver |
| Site fails only on your network, works on mobile data | Router or ISP resolver caching a bad key | Restart router; set DNS manually on the device to bypass the ISP resolver |
| Error appears after you changed DNS settings or moved providers | Old DS records at the registrar still pointing at removed keys | Delete or update the DS records at your registrar to match the new DNS provider's keys |
| Windows log or tool shows "BADKEY" specifically | The response contains a key that can't be used for validation | Treat as a DNSSEC failure; verify DNSKEY and DS alignment before changing anything else |
Why DNSSEC Produces Bad Key Errors
DNSSEC signs DNS records with cryptographic keys. The domain publishes its public keys as DNSKEY records, and the parent zone (usually via your registrar) publishes a DS record, which is a hash of one of those keys. Validators chain the two together: parent hash must match a child key. When the child key is deleted, rotated, or replaced but the DS record still points at the old key, validation fails and resolvers return SERVFAIL, often with a bad key or "no valid key" note in logs. The domain looks perfectly fine to anyone not validating, which is why the failure can look random.
Key rotation gone wrong is the other common path. DNS providers rotate signing keys periodically, and if the rollover sequence is done out of order, there's a window where the published keys and the parent's DS records disagree. That window is exactly when you see bad key errors.
How to Confirm the Diagnosis Before Changing Anything
Run a DNSSEC validation check on the domain using a public DNSSEC testing tool (search for "DNSSEC analyzer" and pick one from a major DNS operator). It shows the chain from the root zone down to the domain's keys and marks the exact link that breaks. If the tool reports a DS mismatch or a missing DNSKEY, the problem is on the domain side and no amount of cache flushing on your machine will truly fix it, though flushing can still clear a stale failure after the owner repairs the records.
To check whether your own resolver is the problem, query the domain directly against a public resolver from a command line: nslookup example.com 8.8.8.8 on Windows, or dig example.com @1.1.1.1 on macOS and Linux. If that query succeeds while your normal browsing fails, your default resolver is the culprit. Menu labels for network settings differ slightly by system version, but the DNS setting lives under network or Wi-Fi advanced options on every major platform.
Fixing Bad Key Errors on a Domain You Run
If the failing domain is yours, the repair is at the registrar and DNS provider, not in browsers. Log in to your DNS provider and confirm the DNSSEC keys currently in use. Then log in to your registrar and compare the DS records there. If the DS records reference keys that no longer exist at the provider, delete the stale DS records or replace them with the current ones your provider lists. Propagation through the parent zone typically takes from a few minutes up to a few hours, and validation failures clear once the chain matches again.
If you've just moved DNS providers, the safest sequence is to remove the old DS records first, wait for the change to propagate, then publish new DS records from the new provider. Doing it in the reverse order is what creates the mismatch in the first place. If you don't need DNSSEC, you can also disable it at the registrar by deleting all DS records, which stops validation failures entirely, at the cost of losing the tamper protection DNSSEC provides.
When the Error Keeps Coming Back
Recurring bad key errors on a domain you control usually mean the DNS provider's automatic key rotation isn't syncing with the registrar's DS records. Check whether your provider supports automatic DS updates; if it does, enable it so rollovers publish matching records without manual work. If it doesn't, plan manual DS updates around each rollover, or turn DNSSEC off rather than leaving a broken chain that makes the site unreachable for validating resolvers. For visitors, the practical answer stays the same: a different resolver bypasses a broken validator, but it can't rescue a domain whose own records are wrong.
Official source: ICANN