Event 8198 With Error 0xC0020017 or 0x8007139F: KMS Contact Failure

Security-SPP event 8198 with error 0xC0020017 or 0x8007139F means the KMS client cannot reach KMS. Fix the KMS host name, forced tunneling, a stuck sppsvc, port 1688 and DNS, with psping, nslookup and slmgr in five steps.

Home › Guides › Event 8198 KMS contact failure

Last updated 22 November 2026

Quick answer

Event ID 8198 from Security-SPP with error code 0xC0020017 or 0x8007139F means the KMS client couldn't contact the Key Management Service. slmgr.vbs /ato only shows a generic failure; the code is in the Application log. Microsoft says 0xC0020017 is functionally similar to 0xC004F074 but comes from a different code path (the SPP event pipeline rather than the SLC API). The usual causes: a firewall or NSG blocks KMS traffic, forced tunneling (VPN, DirectAccess, Always On VPN, ExpressRoute) sends it the wrong way, DNS can't resolve the KMS host, the client points at a wrong KMS host name, or the SPP service is stuck. Work through Microsoft's five steps below, retrying slmgr.vbs /ato after each one.

What the event looks like

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.

8198 is logged for several codes; this guide is for the two that mean "can't reach KMS". Microsoft's PowerShell line to read the last five:

Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Security-SPP'; Id=8198} -MaxEvents 5 | Format-List TimeCreated, Message

If that returns nothing on your system, try the full provider name shown in the event's details, Microsoft-Windows-Security-SPP.

Causes and where to look

CauseWhat happensStep
Wrong KMS targetThe client is set to a KMS host name that is wrong or invalid1: set the host with /ckms and /skms
Forced tunnelingAll outbound traffic goes through a VPN or gateway and bypasses the KMS endpoint2: exempt KMS traffic on port 1688
SPP service stuckThe Software Protection service on the client stops answering properly3: restart sppsvc
Firewall or NSG blocks KMSRules block traffic to the KMS host or service4: test 1688 both ways with PsPing
DNS resolution failureThe client can't reach a DNS server, or the DNS server can't resolve the KMS host (or Azure KMS)5: nslookup and the DNS server list

Microsoft suggests installing Sysinternals PsPing on the client, and on the KMS host if you run your own, before you start.

Step 1: name the KMS host yourself

Skip auto-discovery and tell the client which host to use, in an administrative Command Prompt:

cscript c:\windows\system32\slmgr.vbs /ckms
cscript c:\windows\system32\slmgr.vbs /skms <KMSHost_fqdn>:<KMSHost_Port>
cscript c:\windows\system32\slmgr.vbs /ato

For an Azure VM on Azure KMS, use azkms.core.windows.net and port 1688. Then check whether a new 8198 was logged (same Get-WinEvent line with -MaxEvents 1). If it's still 0xC0020017 or 0x8007139F, go on.

Step 2: VPN, DirectAccess and forced tunneling

If the network routes all client traffic through a gateway, KMS traffic has to be exempted so activation can pass directly over port 1688 between client and KMS host. For Azure VMs using Azure KMS, Microsoft's example is a user-defined route (UDR) that sends traffic for the Azure KMS IP addresses straight to the internet (see Microsoft's "Windows activation fails in forced tunneling scenario"). Retry slmgr.vbs /ato.

Step 3: restart the Software Protection service

On the client, in PowerShell:

Restart-Service sppsvc -Force

Wait 30 seconds, then retry activation.

Step 4: test port 1688 both ways

  1. On the client:
    psping <KMSHost-ip>:1688
    For Azure KMS, Microsoft gives the addresses 20.118.99.224 and 40.83.235.53.
  2. With a self-hosted KMS host, also test from the host back to the client:
    psping <KMSClient-ip>:1688
  3. If either test fails: for an Azure VM, check every NSG on the network interface, subnet and virtual network, and make sure they allow traffic between the VM and its DNS server on UDP/TCP 53. On every firewall in the path, including Windows Firewall on the client, allow UDP/TCP 1688 between client and KMS server. Run PsPing again to confirm.

Step 5: check DNS

  1. On the client, resolve the KMS host against the DNS server it should use:
    nslookup <KMSHost_fqdn> <intendedDNS_name>
    For an Azure VM using Azure DNS, the DNS server is 168.63.129.16 (Microsoft's article writes it with hyphens).
  2. On the KMS host, run ipconfig /all and check every DNS Servers entry. In Microsoft's example, 168.63.129.16 is Azure DNS and 10.0.3.5 and 10.0.3.4 are custom DNS servers.
  3. If the list is empty or wrong, fix it. For Azure VMs with custom DNS servers, set them on the network interface or virtual network, not inside the VM.
  4. After changing DNS settings, restart the KMS host, then run ipconfig /flushdns.

If 8198 with 0xC0020017 or 0x8007139F still comes back after all five steps, Microsoft's next step is a support case. For a client that can't find any KMS host through DNS at all, see 0x8007232A and 0x8007232B.

Related tools and guides

Look up Security-SPP event 8198 in the Windows Event ID Lookup, copy the slmgr, sppsvc and Get-WinEvent lines from the PowerShell Cheat Sheet, pull the error codes out of event 8198 messages with the Regex Tester, check the subnets and routes between clients and the KMS host with the IPv4 Subnet Calculator or IPv6 Subnet Calculator, and identify the vendor of the NIC on an affected VM with the MAC Vendor Lookup. Related guides: KMS activation error 0xC004F074, KMS activation errors 0x8007232A and 0x8007232B, KMS activation errors 0xC004F038 and 0xC004F042 and common Windows DNS Server and DHCP Server errors.

Event 8198 with 0x8007007B on ADBA clients? See ADBA clients not activating. Events 8208, 8200 and 900 with 0x80072EE7 are a different thing: Security-SPP events 8208, 8200 and 900.

Every Windows activation and KMS error code and event in one place: common Windows activation and KMS errors.

FAQ

What does event 8198 with 0xC0020017 mean?

A Windows KMS client cannot contact the Key Management Service for activation. Microsoft says it is functionally similar to 0xC004F074 but is reported by the SPP event pipeline.

Why does slmgr /ato not show the error?

slmgr returns a generic failure code. The real code is in Event ID 8198 from Security-SPP in the Application log; read it with Get-WinEvent filtered on Id 8198.

Can a VPN cause KMS activation to fail?

Yes. With forced tunneling through a VPN, DirectAccess, Always On VPN or an ExpressRoute gateway, KMS traffic can bypass the KMS endpoint. Exempt port 1688 traffic, for Azure with a user-defined route to the Azure KMS addresses.

Which ports does KMS activation need?

Microsoft says to allow UDP/TCP 1688 between client and KMS server on every firewall, and for Azure VMs to allow UDP/TCP 53 between the VM and its DNS server in every NSG.

What are the Azure KMS IP addresses?

Microsoft lists 20.118.99.224 and 40.83.235.53 for testing with psping on port 1688. The host name is azkms.core.windows.net.

Want the full kit?

Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.