Fix Windows RPC_NT_NOT_CANCELLED (0XC0020058) Error
This error means a thread couldn't be canceled in a remote procedure call. Usually it's a timing issue with a slow network resource or a stuck service.
What is the 0XC0020058 Error?
You see RPC_NT_NOT_CANCELLED (0XC0020058) when Windows tries to cancel a thread in a remote procedure call but the thread won't stop. I've hit this on Windows Server 2019 and Windows 10 Pro. It usually appears in event logs or during a system shutdown when a service hangs. The error itself says "The thread was not canceled." That's frustrating because it freezes things.
This tripped me up the first time too. The fix isn't complicated—you just need to find what's blocking the cancellation.
1. Network Timeouts on a Slow Resource
The most common cause: your app or service is waiting on a network resource that's slow or unreachable. For example, a file share on a remote server that's overloaded. The RPC call starts, but when it tries to cancel the thread (maybe during a timeout), the thread ignores the cancel request because it's stuck waiting.
The fix: Increase the RPC timeout. On Windows Server, you can do this via Group Policy or the registry. Here's the registry route:
- Open
regeditas Administrator. - Go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc. If you don't see theRpckey, create it (right-click > New > Key). - Create a DWORD (32-bit) called
DefaultTimeout. Set it to 300000 (decimal) for 5 minutes. Default is 120000 (2 minutes). - Also create a DWORD called
MaximumRpcCallTimeoutand set it to 300000. - Reboot the server.
If you're on a workstation, you can also check your firewall. Sometimes a firewall blocks the RPC dynamic port range. Make sure ports 49152-65535 are open for inbound and outbound.
2. A Stuck Service or Deadlocked Thread
Another scenario: a service like spoolsv.exe (print spooler) or svchost.exe gets into a deadlock. It holds a lock and never releases it. When RPC tries to cancel a thread inside that service, it can't because the thread is waiting on a lock that's held by another thread.
The fix: Restart the affected service. But first, find which service is causing it. Check the System event log for warnings around the same time as the error. Look for a service that's hanging. In my experience, the Windows Time service (W32Time) or the DNS Client service cause this.
To restart a service quickly:
- Open Command Prompt as Admin.
- Type
net stop <servicename>— for example,net stop w32time. If it stops, typenet start w32time. - If it won't stop, use
taskkill /f /im svchost.exebut be careful—that kills all services in that host. Better to usesc queryex <servicename>to get the PID, thentaskkill /pid XXXX /f.
If you see this error repeatedly, check if the service has a dependency that's failing. Use sc qc <servicename> to see dependencies.
3. DCOM Configuration Issues
Less common but real: DCOM (Distributed COM) settings are off. When an RPC call involves COM objects, the DCOM timeout can cause cancellation to fail. This happens a lot with SQL Server or Exchange Server when they talk over the network.
The fix: Adjust DCOM timeouts:
- Open
dcomcnfg(Run > dcomcnfg). - Go to Component Services > Computers > My Computer > Properties.
- Under the Default Protocols tab, ensure TCP/IP is listed and at the top.
- Under the Options tab, set "Enable COM Internet Services" to no (unless you need it).
- Set "Default Authentication Level" to Connect (not None).
- Set "Default Impersonation Level" to Identify.
- Apply and reboot.
You can also set a registry key to increase the DCOM timeout: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole, create a DWORD DefaultLaunchTimeout and set it to 120000 (2 minutes) or higher.
Quick-Reference Summary
| Cause | Symptom | Fix |
|---|---|---|
| Network timeout (slow resource) | Error during file copy or network operation | Increase RPC timeout via registry (DefaultTimeout) or open firewall ports |
| Stuck service or deadlock | System hangs, event log shows service delay | Restart affected service; use taskkill if needed |
| DCOM misconfiguration | Error in SQL Server or Exchange Server | Adjust DCOM settings in dcomcnfg or increase DefaultLaunchTimeout |
I've seen this error most often with network timeouts—especially on Windows Server 2019 when using SMB file shares over VPN. The thread just can't cancel because it's waiting for a network packet that never arrives. Increase the timeout and you're good. If it still happens, check the services next.
Hope this saves you the headache I had. You got this.
Was this solution helpful?