About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
Error 0xC004F038 appears when a Windows system activating against a self-hosted Key Management Service (KMS) host finds that the host has not yet counted enough computers. Microsoft's page gives the thresholds: the KMS count must be at least five for Windows Server-based computers, including virtual machines, and at least 25 for Windows Client-based computers.
Read the count on the KMS host first. The fix is to add unique client computers to the pool and retry activation. The retry changes the computer's license state, and Microsoft's pages describe no way to reverse a successful activation.
What the error means
Microsoft's page "Error 0xC004F038 'The count reported by your Key Management Service (KMS) is insufficient' when you activate Windows" (dated 2026-05-29) applies to supported versions of Azure Virtual Machine, Windows Client and Windows Server. It shows the message in Windows Script Host as: "The Software Protection Service reported that the computer couldn't be activated. The count reported by your Key Management Service (KMS) is insufficient. Please contact your system administrator."
Its cause is stated this way: "Typically, this message indicates that the KMS host doesn't have enough computers in its KMS pool." A self-hosted KMS host, on-premises or in Azure, needs a sufficient number of computers in the pool before it activates anyone. The page adds that Azure VMs that use the default Azure KMS endpoint (azkms.core.windows.net) "typically don't encounter this error because the Azure KMS service handles activation counts automatically."
Microsoft's activation error code table lists 0xC004F038 as a KMS client error with the same message text. A different code, 0xC004F039, is for a KMS that does not respond to the request, and 0xC004F041 is for a KMS host that has not been activated. Those are different faults with their own entries.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The KMS host's count is below the threshold for the client type | 0xC004F038 on clients; the host is reachable | Slmgr.vbs /dli on the KMS host shows the current count |
| The pool holds too few unique KMS clients | The count does not rise as more machines are activated | Microsoft's page says to add "unique KMS client computers" until the count reaches the threshold |
| The computer is an Azure VM that activates against a self-hosted KMS host | The same error on an Azure VM | Microsoft's page says the error "might appear when you use a self-hosted KMS host" and that Azure VMs should use Azure KMS by default; ask the VM's owner which KMS host it is configured to use |
Prove the cause before changing anything
All of these only read. Run them in an elevated Command Prompt (Microsoft's code table says UAC blocks activation processes in a non-elevated window, giving error 0x80070005). On the KMS host:
Slmgr.vbs /dli
Microsoft's page says to run it "in an administrative Command Prompt window on the KMS host computer" to obtain the current count. The Slmgr options page describes /dli as displaying the license information for the installed Windows edition and says the operation does not require elevated privileges, so the count can be read even from a standard prompt on that host.
On the client that shows the error:
cscript c:\windows\system32\slmgr.vbs /dlv
The Slmgr page describes /dlv as the detailed license information for the installed operating system. Record the output: it is your picture of the client before any change.
Compare the host's count with the threshold for the client type: at least five for Windows Server clients, at least 25 for Windows Client clients. If the count is at or above the threshold and activation still fails with this code, Microsoft's page does not cover the case.
Example (illustrative): at contoso.com.au the self-hosted KMS host kms01 serves a new group of Windows Server virtual machines, starting with app01 and rds01. Slmgr.vbs /dli on kms01 shows a count of 3. The threshold for Windows Server clients is five, so app01 and rds01 fail with 0xC004F038 until two more unique Windows Server clients have contacted kms01.
Fix
Raise the count: add unique KMS clients, then retry
Microsoft's step is to add unique KMS client computers until the count reaches the threshold. The page gives no command for that, because it means bringing real computers onto the KMS host, which is the owner's decision.
Microsoft's page says to retry activation on the KMS client once the count reaches the threshold. Before you retry, record the license state:
cscript c:\windows\system32\slmgr.vbs /dlv
Risk: the next command asks this computer to activate against its KMS host. The Slmgr page says that for systems with a Generic Volume License Key installed, /ato "prompts a KMS activation attempt". Activation changes the computer's license state.
Run it only on the failing client, and only after Slmgr.vbs /dli on the KMS host shows that the count threshold has been met. Run Microsoft's retry command in an elevated Command Prompt on that client:
cscript c:\windows\system32\slmgr.vbs /ato
There is no way back from a successful activation in Microsoft's pages, and none is needed for a computer that should be activated. If activation fails again with the same code, the count is still short or the client does not count as unique.
Azure VMs: Azure KMS instead of a self-hosted host
Microsoft's page says Azure VMs "should use Azure Key Management Service (KMS) activation" by default, and that if you don't have to use a self-hosted KMS host you should reconfigure the VM to use Azure KMS. Its steps set the KMS client setup key for the Windows version with /ipk, set the Azure KMS host with /skms azkms.core.windows.net:1688, and run /ato again.
Before you change anything on the Azure VM, record its license information and keep the output with the VM's other records:
cscript c:\windows\system32\slmgr.vbs /dlv
Risk: the Slmgr page says /ipk silently replaces a key that is already installed, and /skms sets the KMS host the VM contacts. Microsoft's pages give no way to read the replaced key back, so /ipk has no back-out. The /ckms command, which the Slmgr page says "removes the specified KMS host name, address, and port information from the registry and restores KMS autodiscovery behavior", removes the /skms setting but does not bring back a host that was set before it.
If your Azure VM is affected, follow Microsoft's own step list, with the owner's approval and with the setup key that matches the edition.
A diagnostic tool Microsoft names
Microsoft's activation error code page says the Microsoft Support and Recovery Assistant (SaRA) "simplifies Windows KMS Activation troubleshooting", and that the tool is intended to resolve activation issues on computers that run Enterprise, Professional or Server editions of Windows. The page offers it as a download and does not describe what it changes on the computer. Treat it as a change to the machine like any other tool, and run it only where a software installation is acceptable.
The same page points to Microsoft's volume activation planning pages for background on how KMS and MAK activation fit together, and to a separate page for general Windows activation messages. Those pages are not part of this fix.
Confirm the fix
- Run
Slmgr.vbs /dlion the KMS host and check the count is at or above the threshold for the client type. - Run
cscript c:\windows\system32\slmgr.vbs /dlion the client. It only displays the license information for the installed edition; compare it with the record you took before. - Run
cscript c:\windows\system32\slmgr.vbs /dlvagain and compare the license information with the record you took before. - Run
slmgr.vbs /xpr. The Slmgr page says the expiration date is "primarily useful for KMS clients", because MAK and retail activation is perpetual.
What to watch afterwards
- The count on the KMS host. Microsoft's page treats the pool size as the cause, so a host whose count falls below the threshold can bring the error back for new clients.
- Whether the count rises after each new client. Microsoft's page asks for unique KMS client computers, so a count that stays still after new machines contact the host is a reason to ask Microsoft Support, which the page names as the next step.
- Other activation codes. 0xC004F039 and 0xC004F041 have their own entries in Microsoft's activation error table.
Read next
Related articles you may want next.
- TroubleshootingWindows activation fails with 0xC004F074: no Key Management Service could be contactedError 0xC004F074 means a volume-licensed Windows computer could not activate against its KMS host. Check the host's service, TCP port 1688, the _VLMCS DNS record, the clock and whether the host can activate this Windows version.Read article
- HostingWindows service recovery settings: automatic restart without hiding the faultWhat the Recovery tab of a Windows service really does: how the failure count and reset period work, why a clean exit with an error may not trigger a restart, why a queued restart cannot be cancelled, and how to set restarts that keep a business application up without hiding a recurring fault.Read article
- Troubleshootingw32tm /resync fails with "The computer did not resync because no time data was available"w32tm /resync says no time data was available. Read the NtpServer value, test UDP 123 and the source, then change it with a saved registry key.Read article
Risks and limits
These commands have not been run or lab-tested.
Microsoft's page gives the thresholds and the cause but does not say how the host decides that a client is unique, or how long the count takes to rise. Microsoft's introduction prints the code as 0xC00F038; the page's title, tables and error list use 0xC004F038. Microsoft's 0xC004F038 text is about self-hosted KMS hosts and does not discuss MAK or retail keys. The Slmgr page says "the Slmgr.vbs script isn't intended to work across platforms" and that using it to manage a Windows 7 or Windows Server 2008 R2 system from the Windows Vista operating system "isn't supported". Changing license settings on production servers belongs in a change window with the license owner's agreement.
Sources
- Error 0xC004F038 "The count reported by your Key Management Service (KMS) is insufficient" when you activate Windows — Microsoft Learn, page dated 2026-05-29, accessed 22 November 2026
- Troubleshoot Windows activation error codes — Microsoft Learn, page dated 2026-02-12, accessed 22 November 2026
- Slmgr.vbs options for obtaining volume activation information — Microsoft Learn, page dated 2025-07-07, accessed 22 November 2026
This article was originally published on .