Windows Servers
Windows Server NTP: Set Up a Time Server with w32tm
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيCorrect time is one of those things nobody notices until it breaks. A server clock that drifts by a few minutes can make Kerberos authentication fail, put log entries from different machines out of order, break scheduled tasks, and cause TLS certificates to look "not yet valid". Windows Server ships with the Windows Time service (W32Time), which can act both as an NTP client and as an NTP server. This guide covers both roles with the w32tm command, plus the special case of Active Directory.
How Windows keeps time
The W32Time service uses the Network Time Protocol (NTP) over UDP port 123. Its behaviour depends on whether the server is in a workgroup or a domain:
- Standalone server (workgroup): syncs from a manually configured list of peers,
time.windows.comby default. - Domain member: syncs from a domain controller following the domain hierarchy.
- Domain controller holding the PDC emulator role in the forest root domain: the authoritative source for the whole forest, and the only machine that should sync from an external source.
Do not confuse time with time zone. Windows keeps the clock in UTC internally; the time zone only changes how it is displayed. Check it with tzutil /g or change it with Set-TimeZone -Id "Egypt Standard Time".
Checking the current state
Open an elevated PowerShell or Command Prompt and run:
w32tm /query /status
w32tm /query /source
w32tm /query /peers
w32tm /query /configuration/source shows where the clock is syncing from. If it says Local CMOS Clock or Free-running System Clock, the server is not syncing from anything on the network, and it will drift.
To measure the offset against an external server without changing anything:
w32tm /stripchart /computer:pool.ntp.org /samples:5 /dataonlyEach line shows the difference between your clock and the remote one.
Configuring Windows as an NTP client
On a standalone VPS, point W32Time at a few reliable public sources:
w32tm /config /manualpeerlist:"0.pool.ntp.org,0x8 1.pool.ntp.org,0x8 2.pool.ntp.org,0x8" /syncfromflags:manual /update
Restart-Service w32time
w32tm /resync /rediscoverThe 0x8 flag tells Windows to use client-mode requests, which is what public NTP servers expect. Using several peers means one unreachable server does not leave you unsynchronised. Make sure the service starts automatically:
Set-Service w32time -StartupType AutomaticTurning Windows Server into an NTP server
If you run several machines, it is cleaner for them to sync from one internal time server than for each to reach the internet. To make a Windows Server answer NTP requests:
# 1. Enable the NTP server provider
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer' -Name Enabled -Value 1
# 2. Sync from upstream sources and announce as a reliable source
w32tm /config /manualpeerlist:"0.pool.ntp.org,0x8 1.pool.ntp.org,0x8" /syncfromflags:manual /reliable:yes /update
# 3. Restart and resync
Restart-Service w32time
w32tm /resync /rediscoverThen allow UDP 123 inbound, limited to the addresses that should use this server:
New-NetFirewallRule -DisplayName "NTP Server" -Direction Inbound -Protocol UDP -LocalPort 123 -RemoteAddress 203.0.113.10,203.0.113.11 -Action AllowReplace the example addresses with your own servers. Do not open UDP 123 to the whole internet: public NTP services attract abuse, and there is no reason to serve time to strangers. If your VPS provider offers a cloud firewall, apply the same restriction there as well.
Test from another Windows machine:
w32tm /stripchart /computer:<your-time-server> /samples:5 /dataonlyOn a Linux client using chrony, add server <your-time-server> iburst to /etc/chrony/chrony.conf (or /etc/chrony.conf), restart chrony and check with chronyc sources.
Time in an Active Directory domain
In a domain, let the hierarchy do its job:
- Find the PDC emulator:
Get-ADDomain | Select-Object PDCEmulatorornetdom query fsmo. - On that domain controller only, configure external peers with
/syncfromflags:manual /reliable:yesas shown above. - On every other domain controller and member server, use the domain hierarchy:
w32tm /config /syncfromflags:domhier /update
Restart-Service w32timeKerberos tolerates a limited clock difference between client and domain controller, five minutes by default. Beyond that, logons and domain joins fail with confusing errors, so time is the first thing to check when authentication breaks. If you are building a domain from scratch, our guide on installing Active Directory covers the PDC emulator's place in the setup.
If you ever move the PDC emulator role to another domain controller, configure the new holder with external peers and switch the old one back to domhier.
Troubleshooting checklist
| Symptom | What to check |
|---|---|
Source is Local CMOS Clock | Peers not configured, or UDP 123 outbound blocked |
| Large offset that does not shrink | Run w32tm /resync /rediscover; check the System log for Time-Service events |
| Clients cannot sync from your server | NtpServer Enabled value, inbound firewall rule, /reliable:yes |
| Domain logons fail intermittently | Offset between member and DC; members must use domhier |
| Settings seem ignored | A Group Policy may override W32Time settings; check with gpresult /h report.html |
If configuration becomes tangled, you can reset the service to defaults with net stop w32time, w32tm /unregister, w32tm /register and net start w32time, then configure it again.
A time server needs very few resources, so a small plan is enough; see the pricing page for options.
FAQ
Which NTP servers should a Windows VPS use?
The pool.ntp.org project, time.windows.com, or your provider's NTP servers are all reasonable choices. Use at least two or three peers so that one unavailable source does not stop synchronisation.
Why does my server clock still drift after configuring NTP?
Usually because W32Time is not actually syncing: the service is stopped, UDP 123 outbound is blocked, or a Group Policy overrides your settings. Check w32tm /query /source and the System log for Time-Service warnings.
Can a domain member sync directly from pool.ntp.org?
It can, but it should not. Domain members should follow the domain hierarchy so all machines share the same time as the domain controllers. Only the PDC emulator of the forest root domain should use external sources.