0XC0020040

Fix RPC_NT_INVALID_NAF_ID (0XC0020040) in Windows

This error means RPC can't find a valid network address family. Usually a corrupted RPC config or IPv6 mismatch. Fix it by rebuilding the RPC endpoint mapper.

Quick answer: Stop and restart the RPC Endpoint Mapper service, then re-register the RPC endpoint using netsh rpc reset from an elevated command prompt. If that doesn't stick, check for a corrupted Winsock or IPv6 stack.

Why this happens

Error 0xC0020040 (RPC_NT_INVALID_NAF_ID) means the Remote Procedure Call runtime can't match the network address family in a binding handle. Usually shows up in app logs when a service tries to listen on an IPv6 endpoint but the stack isn't initialized properly, or when the RPC endpoint mapper database gets corrupted after a failed update or driver install. I've seen it most often on Windows Server 2016 and Windows 10 1809+ after a network adapter driver rollback or an incomplete Windows Update.

Fix steps

  1. Restart the RPC services in order. Open an admin command prompt and run:
    net stop RpcSs && net start RpcSs
    net stop RpcEptMapper && net start RpcEptMapper
    Wait 10 seconds between each.
  2. Reset the RPC endpoint mapper. Still in the admin cmd, run:
    netsh rpc reset
    This rebuilds the RPC endpoint database. Takes about 30 seconds.
  3. Verify IPv6 isn't partially disabled. Check the registry key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents. If it's set to 0xFF, that kills all IPv6 including RPC bindings. Change it to 0 and reboot.
  4. Repair Winsock. Run:
    netsh winsock reset
    netsh int ip reset
    Then reboot. This clears out orphaned socket entries that confuse RPC.

Alternative fixes if that fails

If the error persists, the culprit is almost always a third-party firewall or VPN filter driver hooking into the RPC call chain. Temporarily disable any security software (not just the UI—stop the actual service) and test. Also check for a stale Microsoft Loopback Adapter—I've seen it cause this exact error on multi-homed servers. Remove it if you don't need it.

Another option: manually re-register the RPC endpoint DLLs. Run these from an admin prompt:

regsvr32 rpcrt4.dll
regsvr32 rpcss.dll

Don't bother with System File Checker (SFC) here—it rarely helps with this error because it's not a file corruption problem.

Prevention tip

Always test network driver updates in a staging environment before pushing to production. RPC is finicky about its underlying transport. If you're disabling IPv6 for security reasons, don't do it blindly—use the documented method via the DisabledComponents registry key, and never set it to 0xFF on a domain controller or any server that relies on RPC for management. Instead, use 0x20 to prefer IPv4 but keep IPv6 functional.

Related Errors in Network & Connectivity
0XC00D123A Fix NS_E_PDA_DEVICE_NOT_RESPONDING (0XC00D123A) on WMP 0X00000058 Fix ERROR_NET_WRITE_FAULT (0X00000058) in 3 Steps 0X000025EA DNS_NAME_NOT_IN_ZONE (0x000025EA) - Fix fast Event ID 1001 or 5007 Network Adapter Driver Crash – Fix It Fast

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.