Home / AWS

AWSTroubleshootingIntermediate

EC2 Windows instance not activated: fixing KMS activation errors 0xC004F074, 0x8007232B and 0xC004F06C

A license-included Windows instance on EC2 shows "Activate Windows" or slmgr errors. Check the license type, KMS settings, link-local routes and clock, then reactivate.

Deepak Bhardwaj6 min read

Applies toAmazon EC2 license-included Windows Server 2016, 2019, 2022 and 2025 AMIs; instances from custom AMIs, VM Import and AWS Application Migration Service; AWS Systems Manager Automation

Symptoms

  • The desktop shows an Activate Windows watermark, or Settings reports "Windows isn't activated".
  • slmgr /ato fails with one of these:
Error What it means on EC2 Usual cause
0xC004F074 No KMS server could be contacted Missing or wrong route to 169.254.169.250/251, firewall blocking TCP 1688, wrong KMS server set
0x8007232B DNS name does not exist No KMS server configured, so Windows tries DNS auto-discovery and finds nothing
0xC004F06C Request timestamp is invalid The instance clock is too far from the KMS server's clock
0xC004F074 after everything looks right KMS reachable but activation refused Instance is not license-included (BYOL), or the installed key is not a KMS client key

Amazon-provided Windows AMIs activate against AWS-hosted KMS servers at 169.254.169.250 and 169.254.169.251 on TCP 1688. Instances built from images that came from somewhere else (VM Import, a migrated server, an old EC2-Classic image, a hand-built AMI) are the usual source of problems.

Check 1: is the instance license-included?

AWS only activates instances it bills for Windows. Check the billing platform from the CLI:

aws ec2 describe-instances --instance-ids i-0123456789abcdef0 \
  --query 'Reservations[].Instances[].[InstanceId,PlatformDetails,UsageOperation]' \
  --output table
PlatformDetails UsageOperation Activation through AWS KMS
Windows RunInstances:0002 Yes
Windows with SQL Server ... RunInstances:0006 and similar Yes
Windows BYOL RunInstances:0800 No – you bring your own licence and activation
Linux/UNIX on a Windows guest RunInstances No – the image lost its Windows billing code

If the instance is BYOL or shows Linux/UNIX, the AWS KMS servers will not activate it. You can't change the billing code of a running instance. Either activate with your own licensing (your KMS host or MAK, on Dedicated Hosts where licence terms require it) or rebuild from a license-included AMI, or from an import that used the license-included option.

Warning

Linux/UNIX billing on a Windows guest usually means someone created the AMI from a snapshot with register-image instead of from the instance. Fixing it means migrating the data to a new license-included instance, so plan a maintenance window.

Check 2: what key and KMS server is Windows using?

Run in an elevated PowerShell prompt (Session Manager, EC2 Serial Console or RDP):

cscript //nologo C:\Windows\System32\slmgr.vbs /dlv

Look at:

  • Product Key Channel – it must be Volume:GVLK. Retail or Volume:MAK means a non-KMS key is installed.
  • Registered KMS machine name / KMS machine name from DNS – should be 169.254.169.250:1688.
  • License Status – Licensed, Notification or Initial grace period.

If the channel is wrong, install the generic volume license key (GVLK) for your exact edition and version. Microsoft publishes these on its "Key Management Services (KMS) client activation and product keys" page; copy the key from there rather than from a forum.

cscript //nologo C:\Windows\System32\slmgr.vbs /ipk <GVLK-for-your-edition>

Point Windows at the AWS KMS servers:

cscript //nologo C:\Windows\System32\slmgr.vbs /skms 169.254.169.250:1688

Check 3: can the instance reach 169.254.169.250 on 1688?

Test-NetConnection 169.254.169.250 -Port 1688
Test-NetConnection 169.254.169.251 -Port 1688
route print -4 | Select-String '169.254.169'

AWS Windows AMIs keep persistent /32 routes for the link-local service addresses (169.254.169.123 time, 169.254.169.250/251 KMS, 169.254.169.254 metadata) pointing at the subnet's default gateway. If the image was moved between subnets with different CIDRs, or the network adapter was replaced, those routes can point at a gateway that no longer exists.

Find the current gateway and compare:

Get-NetRoute -DestinationPrefix '0.0.0.0/0' | Select-Object ifIndex, NextHop
Get-NetRoute -DestinationPrefix '169.254.169.*' | Select-Object DestinationPrefix, NextHop, ifIndex

If the KMS routes use a different next hop, replace them. The gateway is the first usable address of the subnet (for example 10.20.1.1 in 10.20.1.0/24):

$gw = (Get-NetRoute -DestinationPrefix '0.0.0.0/0' | Select-Object -First 1).NextHop
foreach ($ip in '169.254.169.250','169.254.169.251') {
    route delete $ip
    route -p add $ip mask 255.255.255.255 $gw
}

Caution

Don't delete the 169.254.169.254 metadata route unless you re-add it straight away. Without it the SSM Agent, the instance profile credentials and EC2Launch stop working and you may lose your Session Manager connection mid-fix.

If routes are correct and the TCP test still fails, look for a host firewall: Windows Defender Firewall outbound rules, a third-party endpoint agent or a hardening GPO that blocks outbound traffic to link-local addresses. An explicit outbound proxy does not affect KMS, because KMS isn't HTTP.

Check 4: is the clock right?

0xC004F06C is almost always clock skew. Use the Amazon Time Sync Service:

w32tm /query /status
w32tm /config /manualpeerlist:169.254.169.123 /syncfromflags:manual /update
Restart-Service w32time
w32tm /resync /force

Domain-joined instances take time from the domain hierarchy instead. In that case fix time on the domain controller holding the PDC emulator role, not on the member.

Activate

cscript //nologo C:\Windows\System32\slmgr.vbs /ato
cscript //nologo C:\Windows\System32\slmgr.vbs /xpr

/xpr should report that the machine is activated, with a renewal date. KMS activations renew automatically, so a working instance stays activated as long as the route and clock stay healthy.

Let Systems Manager do it

If the instance is managed by SSM, the AWS-owned runbook AWSSupport-ActivateWindowsWithAmazonLicense checks and repairs the KMS routes and KMS server settings, then tries to activate:

aws ssm start-automation-execution \
  --document-name AWSSupport-ActivateWindowsWithAmazonLicense \
  --parameters InstanceId=i-0123456789abcdef0

aws ssm get-automation-execution \
  --automation-execution-id <execution-id> \
  --query 'AutomationExecution.[AutomationExecutionStatus,Outputs]'

If the instance isn't reachable through SSM, the runbook has an offline option that stops the instance and repairs it through an EC2Rescue workflow. That means downtime, so check the runbook's parameters in the console before you turn it on for a production server.

Tip

To find every unactivated Windows instance in a fleet, send a Run Command with AWS-RunPowerShellScript that runs Get-CimInstance SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL AND Name LIKE 'Windows%'" | Select-Object Name, LicenseStatus. LicenseStatus 1 means licensed; anything else needs attention.

Prevent it next time

  • Build Windows AMIs from Amazon-provided license-included images with create-image or EC2 Image Builder, never with register-image from a bare snapshot.
  • Leave the AWS KMS routes and 169.254.169.250:1688 setting in place when you harden or sysprep images. Test activation on a fresh launch in a different subnet before you publish the AMI.
  • Add outbound allow rules for 169.254.169.123, 169.254.169.250, 169.254.169.251 and 169.254.169.254 to your firewall baselines.
  • For VM Import or Application Migration Service, choose the license-included option at import time if you want AWS to license Windows. It can't be changed later.
  • Run the license-status Run Command above on a schedule and alert on any instance where it isn't 1.