Skip to content

Est. 2011ยทMicrosoft Partner ID 7033487ยทDelivery under 3 minยทSupport 7 days a week

Your vault is empty.

Free Fix 0x8007139F

Office 0x8007139F and 0xC0020017: the licensing service cannot reach the KMS host

11 min read Updated October 5, 2026 Office & Microsoft 365 Licensing

Fix it now

Microsoft publishes 0x8007139F and 0xC0020017 together, as a KMS contact failure: the Software Protection Platform service on the client cannot reach the KMS host. The activation command itself returns a generic failure, and the real code is written to the Application log as Event ID 8198 from source Security-SPP. Read that event first.

Run these on the failing client, in an elevated PowerShell prompt

Restart-Service sppsvc -Force
nslookup -type=srv _vlmcs._tcp
Test-NetConnection <kms-host> -Port 1688
  1. Open Event Viewer, then Windows Logs, then Application, and find the most recent Event ID 8198 from Security-SPP. That is where the real code is recorded.
  2. If the SRV lookup returns nothing, either fix the record or pin the host by hand: slmgr.vbs /skms <kms-host> and then slmgr.vbs /ato.
  3. If the port test fails, the path is blocked. Check firewall and network security group rules between this subnet and the host, on TCP 1688.
  4. If the machine routes everything through a VPN, confirm the KMS host is reachable inside the tunnel or exempted from it. Forced tunnelling is one of the documented causes.

Restarting the Software Protection service is documented as a step here because the service can be left in a stuck state. It is safe, and it is quicker than the alternatives.

If activation succeeds you can stop here. If not, the next section explains what each of these codes actually reports and which of the other numbers in this family mean nothing published at all.

Why it happens

The raw meaning first, because it is where the confusion starts. 0x8007139F is Win32 error 5023, ERROR_INVALID_STATE, published as “The group or resource is not in the correct state to perform the requested operation”. Read on its own that sounds like local corruption, and a great deal of advice on the internet treats it that way.

Microsoft’s own troubleshooting article for the code says something much more specific. It pairs 0x8007139F with 0xC0020017 and describes both as a KMS contact failure: 0xC0020017 indicates that the Software Protection Platform service on the KMS client cannot contact the KMS host. The state that is wrong is the activation attempt’s, not the licence store’s.

The diagnostic detail that matters is where the code lives. The activation command returns a generic failure and tells you almost nothing. The actual code is written to the Application log as Event ID 8198, source Security-SPP, with the description that licence activation failed and the Software Protection service reported the computer could not be activated. Anyone troubleshooting this from the command line output alone is working blind.

Microsoft names four causes and one condition: firewall or network security group rules blocking traffic to the KMS host; forced tunnelling that routes all outbound traffic through a VPN and past the KMS endpoint; a client that cannot reach a DNS server, or a DNS server that cannot resolve the host; a client pinned to a KMS host name that is wrong or invalid; and the Software Protection service itself being stuck.

Firewall or network rules block the path to the host

You have this one if The host name resolves and Test-NetConnection <host> -Port 1688 reports TcpTestSucceeded False.

  1. Confirm the Key Management Service firewall exception is enabled on the host.
  2. Have the network team check for a rule or network security group dropping TCP 1688 from this subnet.
  3. Test from the client subnet, not from the server. A path that works from the host tells you nothing.

Forced tunnelling is routing the request past the host

You have this one if The client works on the corporate LAN and fails on VPN, or fails everywhere since a tunnelling policy changed.

  1. Confirm whether all outbound traffic is routed through the VPN.
  2. Ask for the KMS endpoint to be exempted from the tunnel, or confirm it is reachable inside it.
  3. Retest the port before retrying activation, so you know whether the change took effect.

DNS cannot answer, or has nothing to answer with

You have this one if nslookup -type=srv _vlmcs._tcp returns a non-existent domain, or the client cannot reach a DNS server at all.

  1. Check the configured DNS servers with ipconfig /all and confirm they are reachable.
  2. Confirm the KMS host is publishing its service record and that the record points at a host that still exists.
  3. Where discovery cannot be fixed today, pin the client: slmgr.vbs /skms <kms-host> then slmgr.vbs /ato.

The client is pinned to the wrong host

You have this one if A host was set by hand or in an image, and that name no longer resolves or no longer runs the service.

  1. Read the current setting from slmgr.vbs /dlv and check what host and port it names.
  2. Set the correct one with slmgr.vbs /skms <kms-host>, or clear it with slmgr.vbs /ckms to return to DNS discovery.
  3. Retry activation and confirm from the event log rather than from the dialog.

For Office specifically, the equivalent ospp.vbs options are /sethst, /setprt and /remhst.

The Software Protection service is stuck

You have this one if Nothing has changed on the network, other clients activate, and this one has been up for a long time.

  1. Run Restart-Service sppsvc -Force from an elevated PowerShell prompt.
  2. Retry activation, then re-read the Application log for a new Event 8198.
  3. If it recurs after every reboot, look at what else is failing on that machine rather than at the licensing store.

Full reference

What each code in this group actually reports

Code Published meaning Source
0x8007139F Win32 5023 ERROR_INVALID_STATE; in an activation context, published with 0xC0020017 as a KMS contact failure Microsoft Learn
0xC0020017 The Software Protection Platform service on the KMS client cannot contact the KMS host Microsoft Learn
0x8007000E Win32 14 ERROR_OUTOFMEMORY: not enough storage is available to complete this operation Microsoft Learn
0x8004E10E Nothing published –
0x8004E105 Nothing published –
0xC004E00A Nothing published on Microsoft’s Office, Windows or volume activation error tables –

Three of those six have no published meaning, and it is worth saying so rather than inventing one. If a dialog shows you 0x8004E105 and nothing else, the useful move is not to look the number up but to read Event 8198 and cscript ospp.vbs /dhistoryacterr, which tell you what the service actually did.

Reading Event 8198

  1. Open Event Viewer, then Windows Logs, then Application.
  2. Filter by source Security-SPP, or by Event ID 8198.
  3. Read the most recent entry from around the time of the failed activation. The description states that licence activation failed and the Software Protection service reported the computer could not be activated, and carries the error code.
  4. Match that code against the table above before doing anything on the machine.
  5. After each change, retry activation and read the next 8198 rather than judging by the dialog, which reports a generic failure either way.

Do not rename the token file under the software protection store folder and rebuild it. That is not part of Microsoft’s documented resolution for these codes, it does not address a KMS contact failure, and on a machine whose Windows activation is currently healthy it puts that at risk for no gain.

Commands for both sides of the conversation

Command What it does Where to run it
slmgr.vbs /dlv Detailed licence status, including the KMS host and port last used Client
slmgr.vbs /skms <host> Pins the client to a named host and disables auto-discovery Client
slmgr.vbs /ckms Clears the pinned host and restores DNS discovery Client
slmgr.vbs /ato Attempts activation now Client
Restart-Service sppsvc -Force Restarts the Software Protection service Client
nslookup -type=srv _vlmcs._tcp Shows whether the KMS service record is published and where it points Client
cscript ospp.vbs /sethst:<host> Sets the KMS host for Office specifically Client
cscript ospp.vbs /dhistorykms Shows the Office KMS client activation history Client

When storage really is the problem

0x8007000E is the one code in this group that is nothing to do with the network. Its published meaning is that not enough storage is available to complete the operation, and after a feature update that usually means disk rather than memory: the previous Windows installation folder is still present and large, and the volume has no room left for the licensing service to write. Free space through Settings, then System, then Storage, and retry before troubleshooting anything else. Removing previous installation files makes rolling the upgrade back impossible, so do that only once the machine is otherwise working.

If it persists after all five causes

  • Confirm the client is actually a KMS client. A machine carrying a MAK will never talk to a KMS host and produces different codes.
  • Confirm the host is activated and has a live count. A host that has not met its threshold refuses clients with its own code.
  • Check whether the host has been moved to a non-default port; the client and the SRV record both have to carry it.
  • Compare the clocks. A large skew between client and host is a documented cause of activation failure generally, even though it is not one of the five listed for these two codes.
  • Microsoft’s own last step for this article is to contact Microsoft Support, which is a reasonable place to stop rather than a failure.

Every code this article covers

Code What it points at Source
0x8007139F Win32 ERROR_INVALID_STATE. In an activation context Microsoft publishes it with 0xC0020017 as a KMS contact failure, logged as Event ID 8198 Microsoft Learn
0xC0020017 The Software Protection Platform service on the KMS client cannot contact the KMS host Microsoft Learn
0x8007000E ERROR_OUTOFMEMORY: not enough storage is available to complete this operation Microsoft Learn
0x8004E10E No published meaning. Read Event 8198 and the activation failure history instead of this number not published by the vendor
0x8004E105 No published meaning. Diagnose from the event log rather than from the code not published by the vendor
0xC004E00A Not listed on Microsoft’s Office activation, Windows activation or volume activation error tables not published by the vendor

Confirm the fix worked

  1. Test-NetConnection <kms-host> -Port 1688 reports TcpTestSucceeded True from the client subnet.
  2. slmgr.vbs /dlv returns a status rather than an error, and names the host you intended.
  3. A new Event 8198 does not appear after the next activation attempt.
  4. On a volume Office install, cscript ospp.vbs /dstatus reports a licensed status.
  5. Restart the machine and confirm it stays activated without anyone touching it.

Questions people ask about this

Was my licence lost in an upgrade?

That is the story usually attached to this code and Microsoft does not publish it. The documented cause is that the Software Protection Platform service cannot reach the KMS host. Entitlements live on your volume agreement or your account and are not damaged by a failed activation attempt.

Why does the command say something different from the event log?

Because the activation command returns a generic failure. Microsoft states the actual error is recorded in the Application log as Event ID 8198, which is why this article starts there rather than at the dialog box.

Should I rebuild the software protection store?

No. It is not in Microsoft’s documented resolution for these codes, it does not address a host that cannot be reached, and it risks the machine’s Windows activation. Work the five documented causes instead.

Why does Windows show as activated while Office does not?

They are licensed by separate mechanisms that share some plumbing, and Office has its own KMS host settings through ospp.vbs. A healthy Windows activation tells you nothing about whether Office can reach its host.

Is slmgr /rearm worth trying?

Not for this. It resets licensing timers and does nothing about a client that cannot reach a host, and used without understanding why it can leave a machine worse off.

Related error codes

Was this article helpful?

Your feedback helps us improve our documentation.

Related articles

Free Fix Office 0x80070005: activation fails with an access denied error License Error Office 0xC004F074: no Key Management Service host could be contacted Free Fix Office 0xC004F06C: the KMS request timestamp is invalid (clock skew) License Error Office 0xC004C020: your MAK key has run out of available activations
โ† Back to Knowledge Base