This article explains how to resolve Event ID 8198 if it includes error code 0xC0020017 or 0x8007139F. These codes, when they occur in this event, indicate that a Windows KMS client can't contact the Key Management Service (KMS) for activation.
The troubleshooting steps in this article walk you through the most common causes, including VPN or tunneling configuration issues, incorrect client settings, and network connectivity problems. The steps apply to physical computers, on-premises virtual machines (VMs), and Azure VMs.
Symptoms
When you try to activate a Windows system, the standard slmgr.vbs /ato command returns a generic failure code. However, the actual error is recorded in the application log as Event ID 8198. The event content resembles the following example:
Source: Security-SPP
Event ID: 8198
Error code: <ErrorCode>
Description: License Activation failed. The Software Protection service reported that the computer couldn't be activated.
Note:
In the event output, <ErrorCode> represents one of several error codes. For the issue that's discussed in this article, the error code is either0xC0020017or0x8007139F.
To view this event, open Windows PowerShell on the client, and then run the following cmdlet:
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 5 | Format-List TimeCreated, Message
Cause
Error 0xC0020017 indicates that the Software Protection Platform (SPP) service on the KMS client can't contact the KMS host. This error is functionally similar to error 0xC004F074, but it comes from a different code path. The SPP event pipeline reports this error instead of the System-Level Cache (SLC) API.
This issue might occur in any of the following scenarios:
- Firewall blocks KMS traffic: Firewall rules or Network Security Group (NSG) rules block traffic to the KMS host or service.
- Forced tunneling: All outbound traffic is routed through a VPN or similar technology, bypassing the KMS endpoint. For example, if you implement DirectAccess, Always On VPN, or Azure ExpressRoute gateway, you might encounter this issue.
- DNS resolution failure: The KMS client can't connect to a DNS server, or the DNS server can't resolve the address of the KMS host (or Azure KMS service, for Azure VMs).
- Wrong KMS target: The client is configured to use a specific KMS host, but the KMS host name is incorrect or invalid.
- SPP service issue: the SPP service itself might be in a stuck state.
Resolution
To troubleshoot and fix this issue, use the following steps. To get the best results from this procedure, install the PsPing tool on the affected computer. If you have a self-hosted KMS server, install the PsPing tool on that computer, also.
You should also be familiar with the slmgr script.
Step 1: Activate by using a particular KMS host
To bypass the automatic discovery process, you can use the slmgr script to specify a KMS host:
-
Open an administrative Command Prompt window on the client.
-
To clear any existing KMS host setting, run the following command:
cscript c:\windows\system32\slmgr.vbs /ckms -
To specify a KMS host for activation, run the following command:
cscript c:\windows\system32\slmgr.vbs /skms <KMSHost_fqdn>:<KMSHost_Port>[!NOTE]
- In this command, <KMSHost_fqdn> represents the fully qualified domain name (FQDN) of the KMS host, and <KMSHost_Port> represents the port that the KMS host uses.
- To activate an Azure VM by using the Azure KMS service, use
azkms.core.windows.netfor <KMSHost_fqdn>, and use1688for <KMSHost_Port.
-
To try again to activate, run the following command:
cscript c:\windows\system32\slmgr.vbs /ato -
To check whether the issue reoccurs, run the following command at the PowerShell command prompt:
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 1 | Format-List TimeCreated, Message
If the activation process still generates Event ID 8198 (error code 0xC0020017 or 0x8007139F), go to Step 2.
Step 2: Check the VPN, Direct Access, forced tunneling, or similar configuration
If your virtual network routes all client traffic through a gateway (forced tunneling), you must exempt KMS traffic.
-
Review your tunneling configuration, and make sure that activation traffic can pass directly over port 1688 between clients and the KMS host.
For example, for Azure VMs that use Azure KMS, add a user-defined route (UDR) that sends traffic for the Azure KMS IP addresses directly to the internet. For information about how to configure this exemption for Azure, see Windows activation fails in forced tunneling scenario.
-
To try again to activate Windows, run the following command at the command prompt on the client:
cscript c:\windows\system32\slmgr.vbs /ato -
To check whether the issue reoccurs, run the following command at the PowerShell command prompt:
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 1 | Format-List TimeCreated, Message
If the activation process still generates Event ID 8198 (error code 0xC0020017 or 0x8007139F), go to Step 3.
Step 3: Restart the SPP service
In some cases, the SPP service itself might be in a stuck state.
-
To restart the SPP service, run the following command at the PowerShell command prompt on the client:
Restart-Service sppsvc -Force -
Wait 30 seconds.
-
To try again to activate Windows, run the following command at the command prompt on the client:
cscript c:\windows\system32\slmgr.vbs /ato -
To check whether the issue reoccurs, run the following command at the PowerShell command prompt:
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 1 | Format-List TimeCreated, Message
If the activation process still generates Event ID 8198 (error code 0xC0020017 or 0x8007139F), go to Step 4.
Step 4: Make sure that activation traffic can pass between the client and the KMS host
-
Run the following command at the command prompt on the client:
psping <KMSHost-ip>:1688[!NOTE]
- In this command, <KMSHost_ip> represents the IP address of the KMS host.
- If the client is an Azure VM, and you're using the Azure KMS service for activation, use
20.118.99.224or40.83.235.53for <KMSHost-ip>.
-
If you're using a self-hosted KMS host, open an administrative Command Prompt window on the KMS host, and then run the following command:
psping <KMSClient-ip>:1688[!NOTE]
In this command, <KMSClient_ip> represents the IP address of the client. -
If
pspingfails in either case, follow these steps:-
For an Azure VM, check any network security groups (NSGs) that might affect the VM (such as NSGs that are set at the network interface, subnet, or virtual network level). Make sure that any NSG allows traffic between the VM and the DNS server on UDP/TCP port 53.
-
Make sure that any firewall (including Windows Firewall on the client) allows traffic between the client and the KMS server on UDP/TCP port 1688.
-
To verify that traffic is unblocked, run
pspingagain.
-
-
To try again to activate Windows, run the following command at the command prompt on the client:
cscript c:\windows\system32\slmgr.vbs /ato -
To check whether the issue reoccurs, run the following command at the PowerShell command prompt:
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 1 | Format-List TimeCreated, Message
If the activation process still generates Event ID 8198 (error code 0xC0020017 or 0x8007139F), go to Step 5.
Step 5: Check the DNS configuration
-
To check the DNS configuration, run the following command at the command prompt on the client:
nslookup <KMSHost_fqdn> <intendedDNS_name>[!NOTE]
- In this command, <KMSHost_fqdn> represents the FQDN of the KMS host, and <intendedDNS_name> represents the FQDN or IP address of the DNS server that the client should use to contact the host.
- If the client is an Azure VM that uses the Azure DNS service, use
168-63-129-16for <intendedDNS_name>.
-
If the client is an Azure VM, and you're using the Azure KMS service, and the
nslookupcommand failed, see the following articles to troubleshoot your DNS configuration: -
On the KMS host, open an administrative Command Prompt window, and then run the following command:
ipconfig /allThe output of this command should resemble the following examples:
DNS Servers . . . . . . . . . . . : 168.63.129.16DNS Servers . . . . . . . . . . . : 10.0.3.5 10.0.3.4[!NOTE]
In this example,168.63.129.16is the IP address that Azure VMs use when they connect to the Azure DNS infrastructure. The other IP addresses represent custom DNS servers. -
Verify that each of the DNS server addresses is correct.
[!IMPORTANT]
When you use custom DNS servers for Azure VMs, don't configure the DNS server settings on the VM itself. Specify DNS servers at the level of the network interface or the virtual network. -
If the list of DNS server addresses is empty or doesn't include the correct addresses, see the following articles for more information:
-
If you change any DNS settings, restart the KMS host.
-
After the KMS host restarts, open an administrative Command Prompt window, and then run the following command:
ipconfig /flushdnsThis command flushes and rebuilds the DNS cache.
-
To try again to activate Windows, run the following command at the command prompt on the client:
cscript c:\windows\system32\slmgr.vbs /ato -
To check whether the issue reoccurs, run the following command at the PowerShell command prompt:
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 1 | Format-List TimeCreated, Message
If the activation process still generates Event ID 8198 (error code 0xC0020017 or 0x8007139F), contact Microsoft Support.
References
- Windows activation fails in forced tunneling scenario
- Error 0xC004F074 - No KMS could be contacted
- DNS troubleshooting guidance
- Guidelines for troubleshooting DNS-related activation issues
- Troubleshooting tools for Windows activation issues on Azure VMs
- Configure DNS name resolution for Azure virtual networks
- Azure IP address 168.63.129.16 overview
Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
