0X000020E4

Fix ERROR_DS_CANT_FIND_EXPECTED_NC (0X000020E4) fast

AD can't find a naming context (NC) it expects. Usually a replication issue after a failed domain controller demotion or DNS misconfig.

First thing: check DNS and replication

I've seen 0X000020E4 more times than I care to count. Nine times out of ten, it's because a domain controller got demoted or yanked out of the network without proper cleanup. The error literally means Active Directory is looking for a naming context (NC)—like DC=domain,DC=com or a domain partition—and can't find it on the server you're querying. The naming context itself still exists in the forest, but the metadata or DNS points to a dead server.

First, check DNS on the failing DC. Open DNS Manager, expand your forward lookup zone, and look under _msdcs.<yourdomain>. If you see old SRV records pointing to a DC that no longer exists, that's your problem. Delete them. Also check the _tcp folder for stale LDAP or Kerberos records. I had a client last month whose entire print queue died because of this—a single stale SRV record made the print server think it couldn't find the domain. Took me 10 minutes to clean it up.

Run this from an elevated command prompt to verify replication:

repadmin /replsummary

If you see failures with 0X000020E4, the source DC listed in the error is likely gone. The fix is metadata cleanup, covered below.

Cause 1: Orphaned domain controller metadata

This is the most common cause. When you demote a DC using dcpromo or Server Manager, it should clean up its own metadata. But if the demotion fails halfway, or if someone just turned off the server, the metadata sticks around in AD and DNS. Other DCs still try to replicate with the ghost DC, get 0X000020E4, and stop replicating.

Fix: Clean up metadata using ntdsutil. This isn't hard, but you need to be careful. Do this on a working DC (preferably the one holding the PDC emulator role).

  1. Open an elevated command prompt.
  2. Type ntdsutil and press Enter.
  3. Type metadata cleanup and press Enter.
  4. Type connections and press Enter.
  5. Type connect to server <your working DC> (e.g., connect to server DC01).
  6. Type quit to exit connections.
  7. Type select operation target and press Enter.
  8. Type list domains — note the domain index number (usually 0).
  9. Type select domain 0 (or whatever index your domain is).
  10. Type list sites — note your site index.
  11. Type select site <site index>.
  12. Type list servers in site — find the dead DC and note its index.
  13. Type select server <dead DC index>.
  14. Type quit to go back to metadata cleanup menu.
  15. Type remove selected server — confirm the prompt.
  16. Type quit twice to exit.

After that, run repadmin /syncall /AdeP on the remaining DCs to force replication. If the error was on a specific server, give it a few minutes and check dcdiag /test:replications.

I once spent two hours on a call with a client who swore they'd demoted the DC properly. Turned out they'd used the Windows GUI but the server had a pending reboot. Metadata was still there. The fix above took 3 minutes.

Cause 2: DNS missing or wrong SRV records for the naming context

If metadata cleanup didn't fix it, the problem is probably DNS. AD relies on SRV records to locate naming contexts. If a DC that hosted a specific NC (like CN=Schema,CN=Configuration,DC=...) is gone but its SRV records remain, other DCs will try to replicate and fail.

Fix: Use ADSI Edit to verify the naming context references, then fix DNS. First, open ADSI Edit on a working DC. Right-click ADSI Edit in the left pane and choose Connect to. Under Select a well-known Naming Context, choose Configuration. Navigate to CN=Sites,CN=Configuration,DC=..., expand your site, then CN=Servers. Find the dead server entry and delete it. This removes it from AD completely.

Then, check DNS again. Delete any SRV records under _msdcs, _tcp, _udp, and _sites that point to the dead DC. You can do this manually in DNS Manager or script it. If you're in a hurry, run this on a working DC to force registration of proper SRV records:

ipconfig /registerdns

Then restart the Netlogon service on all DCs (net stop netlogon && net start netlogon).

Had a client with a multi-site setup where a remote DC was decommissioned but DNS scavenging was off. Stale records from 2019 were still there. Took me 30 minutes to clean all three sites. After that, replication flew.

Cause 3: Replication from a retired or non-existent domain controller

Sometimes the error shows up on a DC that's still alive but trying to replicate an NC from a DC that was never properly demoted. This is common in environments where someone built a temporary DC for a migration and forgot to clean up.

Fix: Use repadmin to list and remove stale replication partners. Open an elevated command prompt on the DC showing the error. Run:

repadmin /showrepl

Look for entries under DSA object GUID or Source DC that show a failed NC with 0X000020E4. Note the GUID of the dead DC.

Then, remove that source as a replication partner:

repadmin /options <localDC> +DISABLE_INBOUND_REPL

Wait a minute, then re-enable:
repadmin /options <localDC> -DISABLE_INBOUND_REPL

This forces the local DC to re-evaluate its replication topology. After that, run repadmin /syncall /AdeP again.

If the GUID is from a dead DC you already cleaned metadata from, you might need to force removal using ADSI Edit—navigate to CN=NTDS Settings under the dead server object in Configuration and delete the CN=NTDS Settings object.

One time I saw this on a 2012 R2 DC that was still trying to replicate a read-only domain controller that had been physically destroyed. The repadmin /options trick fixed it instantly.

Quick-reference summary

CauseFixTools
Orphaned DC metadataClean up with ntdsutil, then force replicationntdsutil, repadmin
Stale DNS SRV recordsRemove old SRV records, register fresh onesDNS Manager, ipconfig, net stop/start netlogon
Replication partner from dead DCDisable/re-enable inbound replication, delete NTDS Settingsrepadmin, ADSI Edit

If the error persists after all that, check for lingering objects using repadmin /removelingeringobjects on the NC. But honestly, 95% of the time it's one of those three. Start with metadata cleanup—it's the most common reason I see this code in the field.

Related Errors in Windows Errors
0X00002164 Fix ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY (0x2164) 0XC0360005 Fix STATUS_IPSEC_INVALID_PACKET (0XC0360005) quick 0XC00A0014 STATUS_CTX_LICENSE_EXPIRED (0xC00A0014) – Fix Terminal Server License 0XC0000718 Stop 0XC0000718: Callback Already Registered Fix

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.