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