Symptoms
A VM's clock is minutes off and something that checks timestamps starts failing:
| Symptom | Where you see it | Why time matters |
|---|---|---|
KRB_AP_ERR_SKEW, "The time difference between the client and server", domain logons fail | Windows event logs, SSSD/realmd on Linux | Kerberos rejects tickets outside the allowed skew (5 minutes by default) |
AADSTS700024: Client assertion is not within its valid time range | App or pipeline using a certificate credential | The signed assertion's nbf/exp claims are judged against Entra ID's clock |
Storage returns 403 AuthenticationFailed with "Request date header too old" | SDK or REST calls to Blob, Queue, Table | Shared key requests carry a date that must be close to the service's time |
| "Certificate is not yet valid" or "expired" on a fresh certificate | curl, browsers, .NET, Java | Validity windows are checked against the local clock |
| TOTP codes rejected, cron jobs at the wrong time, log lines out of order | Anywhere | The clock is simply wrong |
How Azure VMs keep time
Azure hosts expose their clock to guests through Hyper-V integration services, so a VM can stay in sync without reaching any network time server.
- Linux: the
hv_utilsdriver exposes a PTP hardware clock. Recent endorsed images create a udev symlink/dev/ptp_hyperv; older ones only have/dev/ptp0(or another number). chrony reads it as arefclock PHC. - Windows: the VM IC Time Synchronization Provider (
VMICTimeProvider) feeds w32time from the host. Standalone VMs also use NTP totime.windows.com. Domain members follow the domain hierarchy (NT5DS).
Most drift comes from one of three things. The host source has been disabled or misconfigured. The VM depends on an NTP server it can't reach. Or two time daemons are fighting over the clock.
Check 1: how far off is the VM?
You can measure from outside without logging in by using Run Command:
RG=rg-app; VM=vm-app01
# Linux
az vm run-command invoke -g $RG -n $VM --command-id RunShellScript \
--scripts "date -u; chronyc tracking; chronyc sources -v" \
--query "value[0].message" -o tsv
# Windows
az vm run-command invoke -g $RG -n $VM --command-id RunPowerShellScript \
--scripts "(Get-Date).ToUniversalTime(); w32tm /query /source; w32tm /query /status" \
--query "value[0].message" -o tsv
Compare date -u or the PowerShell UTC time with a known-good clock. In chronyc tracking, look at System time (the current offset) and Leap status (Normal is good, Not synchronised is not).
Tip
To sweep a fleet, loop the same Run Command over
az vm list -g $RG --query "[].name" -o tsv. Run Command executes one script per VM at a time, so run them in sequence or in small batches.
Check 2 (Linux): is chrony using the Hyper-V clock?
ls -l /dev/ptp* # expect ptp0 and, on newer images, ptp_hyperv -> ptp0
cat /sys/class/ptp/ptp0/clock_name # expect "hyperv"
chronyc sources -v # the PHC line should be marked with '*' (selected)
grep -E "^(refclock|server|pool|makestep)" /etc/chrony.conf /etc/chrony/chrony.conf 2>/dev/null
systemctl is-active chronyd chrony systemd-timesyncd ntpd 2>/dev/null
timedatectl status
What healthy looks like in chronyc sources:
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#* PHC0 0 3 377 6 +12us[ +15us] +/- 1500ns
| Finding | Cause | Fix |
|---|---|---|
No refclock PHC line in the config | Custom or hardened image with the Azure config removed | Add the refclock line below |
refclock PHC /dev/ptp_hyperv but the device doesn't exist | Older image without the udev rule | Point it at the right /dev/ptpN, after checking that clock_name says hyperv |
PHC source shows ? or Reach 0 | Wrong device, or hv_utils not loaded | lsmod | grep hv_utils, then fix the device path |
Only pool/server lines, all with ? | Outbound UDP 123 blocked by an NSG, firewall or forced tunnel | Use the PHC refclock. It needs no network |
chronyd and systemd-timesyncd (or ntpd) both active | Two daemons stepping the clock | Disable all but chrony |
The configuration Microsoft documents for Azure looks like this. File paths vary by distribution (/etc/chrony.conf on RHEL and SLES, /etc/chrony/chrony.conf on Ubuntu):
refclock PHC /dev/ptp_hyperv poll 3 dpoll -2 offset 0 stratum 2
makestep 1.0 -1
Apply it and correct the clock right away:
sudo systemctl disable --now systemd-timesyncd 2>/dev/null
sudo systemctl restart chronyd 2>/dev/null || sudo systemctl restart chrony
sudo chronyc makestep
chronyc tracking
Warning
chronyc makestepjumps the clock instead of slewing it. A large backwards step can confuse databases, message brokers and anything that orders events by local time. On a database or cluster node, step during a quiet window, or let chrony slew small offsets.
Check 3 (Windows): what is w32time actually using?
w32tm /query /source
w32tm /query /status
w32tm /query /configuration
w32tm /query /peers
w32tm /stripchart /computer:time.windows.com /samples:5 /dataonly
w32tm /query /source returns | Meaning | Action |
|---|---|---|
VM IC Time Synchronization Provider | Syncing from the Azure host | Normal for standalone VMs |
time.windows.com,0x8 (or your NTP server) | Syncing over NTP | Check that UDP 123 outbound is allowed |
| A domain controller name | Domain hierarchy | Check the DC, and ultimately the PDC emulator |
Local CMOS Clock or Free-running System Clock | Not syncing at all | Fix the configuration below |
Check that the host provider is enabled:
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider" -Name Enabled
On a standalone (workgroup) VM that has drifted, set a reachable NTP peer, keep the host provider on, then resync:
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider" -Name Enabled -Value 1
w32tm /config /manualpeerlist:"time.windows.com,0x8" /syncfromflags:manual /update
Restart-Service w32time
w32tm /resync /rediscover
w32tm /query /status
On a domain member, don't hard-code peers. Run w32tm /config /syncfromflags:domhier /update, restart w32time and resync. If several members are wrong by the same amount, the problem is the DC.
Caution
The PDC emulator is the time source for the whole forest. Changing its configuration or stepping its clock moves every domain member with it. Check the current setup with
w32tm /query /configurationandw32tm /monitorfirst. Make one deliberate change, and follow Microsoft's current guidance for domain controllers hosted in Azure. Don't leave a mix of host sync and external NTP that nobody chose on purpose.
Check 4: can the VM reach its NTP server?
This only matters if the VM relies on NTP rather than the host clock:
# Effective NSG rules on the NIC, looking for outbound UDP 123
az network nic list-effective-nsg -g $RG -n vm-app01-nic \
--query "value[].effectiveSecurityRules[?direction=='Outbound' && (destinationPortRange=='123-123' || destinationPortRange=='0-65535')].{name:name,access:access,prio:priority}" -o table
# From inside a Linux VM
chronyc -N sources
With a forced tunnel to on-premises, or an Azure Firewall without a rule for UDP 123, NTP queries just time out. Either allow the flow or rely on the host clock, which needs no network access.
Prevent it next time
- Keep the Azure time configuration in your golden images. Hardening scripts often strip the
refclock PHCline or turn off the VMIC provider. - Run exactly one time daemon on Linux. Mask
systemd-timesyncdif chrony is the standard. - Add a scheduled check, through Run Command, Azure Policy guest configuration or your monitoring agent, that alerts when the
chronyc trackingoffset or thew32tm /query /statussource looks wrong. - Document the AD time hierarchy, especially which source the PDC emulator uses, and review it after DC migrations.
- Treat
KRB_AP_ERR_SKEWandAADSTS700024as time problems first. Check the clock before you rotate credentials.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get