What is an NTP server? How time sync works on servers

What an NTP server does, why a wrong clock breaks HTTPS and logins, and how to check, change and serve time sync on Linux.

8–11 minutes
Front panels of rack-mounted servers

An NTP server is a computer that tells other computers the exact time over the network, so their clocks agree to within a few thousandths of a second. This guide is for anyone running a website or a Linux server who wants to know what NTP does, why a wrong clock breaks things, and how to check and set up time sync properly.

NTP (Network Time Protocol) keeps clocks accurate by asking time servers for the time over UDP portPort A numbered door on a server. Each service listens behind its own door: web pages on 443, email on others, remote login on 22. More about Port → 123 and gently correcting the local clock. Most servers should not run their own NTP server: they only need an NTP client pointed at a reliable public source such as pool.ntp.org. On Linux, run **timedatectl and look for “System clock synchronized: yes”** to confirm it is working.

What an NTP server actually does

Every computer has a hardware clock, and every hardware clock drifts. A cheap crystal can gain or lose several seconds a week, and virtual machines can drift faster when their host is busy. NTP fixes this by letting a computer compare its clock with a better one over the network.

The comparison is cleverer than just asking “what time is it?”. The client notes when it sent the question and when the answer arrived, and the server notes when it received the question and when it replied. From those four timestamps the client works out both how far its clock is off (the offset) and how long the network trip took (the delay), so a slow connection does not make the clock wrong. It repeats this every few minutes against several servers, throws out the ones that disagree, and nudges its own clock towards the rest.

NTP is one of the oldest protocols still in daily use. The current version, NTPv4, is defined in RFC 5905. It runs over UDP on port 123, which matters later when you deal with firewallsFirewall A gatekeeper that decides which connections are allowed into a server and blocks the rest. More about Firewall →.

Strata: how time flows down

NTP servers are arranged in layers called strata:

StratumWhat it isExample
0A reference clock, not on the network itselfGPS receiver, atomic clock, radio time signal
1A server wired directly to a stratum 0 clockA national time lab’s public server
2A server that syncs from stratum 1 serversMost large public pools
3 and belowServers that sync from the layer aboveYour company’s internal time server, your own server
16Not synchronised at allA server that has lost every source

A lower number is closer to the reference clock, but not automatically better for you. A nearby, stable stratum 2 server usually gives better results than a distant, overloaded stratum 1.

NTP client and NTP server are the same software

The program that keeps your server’s clock right is an NTP client. Some of these programs, such as chrony, can also serve time to other machines if you allow it. So “setting up an NTP server” can mean two different things: pointing your server at good time sources (what almost everyone needs) or letting other machines on your network get the time from it (what a few people need).

Why accurate time matters on a server

A clock that is a few minutes out sounds harmless. In practice it breaks things that rely on time quietly and confusingly:

  • HTTPSHTTPS The secure version of the web, shown by the padlock. Everything sent between you and the site is scrambled so nobody in between can read or change it. More about HTTPS → certificates. Every SSL certificate has a start and end date. If a clock is far enough wrong, valid certificates look expired or not yet valid, and connections fail.
  • Two-factor codes. Authenticator app codes change every 30 seconds and are worked out from the current time. A server whose clock is off by a minute or more can reject every correct code.
  • Logs. When you are tracing a problem across a web serverWeb server The program that answers visitors’ browsers and sends them your website. Also used for the computer it runs on. More about Web server →, a database and a mail server, you need their timestamps to line up. Otherwise events appear in the wrong order.
  • Scheduled jobs. Cron jobsCron job A task the server runs by itself on a timetable, like an alarm clock for jobs. For example, making a backup every night at 3 a.m. More about Cron job → and backups run at the wrong moment, or twice, or not at all if the clock jumps.
  • Logins and clusters. Systems such as Kerberos refuse logins when clocks differ by more than a few minutes, and database replication can misbehave when servers disagree about the time.

NTP prevents all of this, and on modern Linux distributions it is switched on by default. The job is usually just to confirm it is working.

Which NTP software your server uses

Linux has three common time sync programs. You only want one of them running at a time.

ProgramDefault onCan serve time to others?Notes
systemd-timesyncdUbuntu 22.04 and 24.04, many Debian installsNoA lightweight client using a simplified form of NTP (SNTP). Fine for most single servers.
chronyAlmaLinux, Rocky Linux and RHEL 8 and 9, Ubuntu 25.10 and laterYesAccurate, copes well with virtual machines and laptops, supports NTS.
ntpdOlder systemsYesThe original reference program. Still works, but chrony has replaced it on most distributions.

If you install chrony on Ubuntu, the package manager removes systemd-timesyncd for you, because the two conflict. Running two time programs at once makes them fight over the clock.

How to check that time sync is working

On any modern Linux server

Run:

timedatectl

The lines that matter look like this:

               Local time: Sat 2026-11-07 09:14:02 UTC
           Universal time: Sat 2026-11-07 09:14:02 UTC
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active

System clock synchronized: yes means the clock is being kept in step. NTP service: active means a sync program is running. If the service is inactive, turn it on:

sudo timedatectl set-ntp true

With systemd-timesyncd (Ubuntu and Debian)

timedatectl timesync-status

This shows the server it is using, the last offset and how often it polls. On Ubuntu the default server is ntp.ubuntu.com.

With chrony (AlmaLinux, Rocky Linux, newer Ubuntu)

chronyc tracking
chronyc sources -v

chronyc tracking shows the current source, the stratum and the “System time” line, which is how far the clock is from the true time. A healthy server shows a value in milliseconds or less. chronyc sources -v lists every source with a symbol in front: * marks the one currently in use, + marks good sources being combined with it, and ? or x mark sources that are unreachable or rejected.

How to change the NTP servers you sync from

The defaults are fine for most people. You might change them if your host or company runs its own time server, or if you want a specific public service.

systemd-timesyncd

Edit the configuration file:

sudo nano /etc/systemd/timesyncd.conf

Under the [Time] section, set your servers on one line, separated by spaces:

[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org
FallbackNTP=ntp.ubuntu.com

Then restart the service and check the result:

sudo systemctl restart systemd-timesyncd
timedatectl timesync-status

chrony

The configuration file is /etc/chrony.conf on AlmaLinux and Rocky Linux, and /etc/chrony/chrony.conf on Ubuntu and Debian. Replace the existing pool or server lines with your choice:

pool pool.ntp.org iburst

pool tells chrony to use several servers behind one name; server names a single server. iburst sends a quick burst of requests at start-up so the first sync happens in seconds rather than minutes. Restart and check:

sudo systemctl restart chronyd
chronyc sources -v

On Ubuntu and Debian the service is called chrony rather than chronyd.

Choosing a time source

  • pool.ntp.org is a large volunteer project that hands out a nearby server each time you look up the name. It is the usual default.
  • Your hosting provider’s time server, if they publish one, is often the closest and most reliable choice for a server in their network.
  • Large public services run by operating system vendors and big networks also offer free NTP.

Some public time services “smear” leap seconds, spreading the extra second over many hours, while others do not. Do not mix the two kinds in one configuration, or your server will see them disagree around a leap second.

How to run your own NTP server for a network

You only need this if you have several machines that should share one consistent clock, such as servers on a private network that cannot reach the internet. Install chrony, let it sync from public sources as above, then allow clients to ask it for the time.

  1. Add an allow line to the chrony configuration file with the network your clients use, for example allow 192.0.2.0/24.
  2. Restart chrony with sudo systemctl restart chronyd (or chrony on Ubuntu and Debian).
  3. Open UDP port 123 in the firewall, ideally only to that network. With UFW: sudo ufw allow from 192.0.2.0/24 to any port 123 proto udp. With firewalld: sudo firewall-cmd --permanent --add-service=ntp followed by sudo firewall-cmd --reload.
  4. Point each client at your server’s address and check with chronyc sources on the client.
  5. On the server, run sudo chronyc clients to see which machines are asking it for the time.

Without an allow line chrony does not answer anyone else, which is the safe default. Do not open port 123 to the whole internet unless you mean to run a public time server: open NTP servers have been abused in the past to amplify attacks.

Secure time with NTS

Plain NTP is not encrypted or signed, so an attacker on the network path could in theory feed your server a false time. Network Time Security (NTS, RFC 8915) adds authentication. Chrony 4.0 and later supports it: add nts to the end of a server line that points at an NTS-capable server. NTS needs TCP port 4460 open outbound for its first key exchange, as well as UDP 123.

Common problems

SymptomCauseFix
“System clock synchronized: no”No sync service running, or it cannot reach any serverRun sudo timedatectl set-ntp true, then check outbound UDP 123 is allowed
chronyc sources shows only ?The server cannot reach its time sourcesCheck DNS resolution and any firewall or host network rule blocking UDP 123
Clock is right but shows the wrong hourTime zone is set wrongly, not the clockSet it with sudo timedatectl set-timezone Europe/London (or your zone)
Clock is hours off and chrony corrects it very slowlychrony adjusts large errors gradually after start-upRun sudo chronyc makestep once to jump straight to the correct time
set-ntp true fails with “NTP not supported”No time sync program is installedInstall one: sudo apt install systemd-timesyncd or sudo dnf install chrony
Clients cannot sync from your own NTP serverMissing allow line or port 123 closedAdd the client network to allow, open UDP 123 to it, restart chrony

Servers almost always run on UTC, whatever country they are in. It avoids confusion during daylight saving changes and makes logs from different machines easy to compare. NTP itself only deals in UTC; the time zone is just how the time is displayed.

Official documentation

Get the next guide

One email when there is something worth reading: new guides, errors going around, and hosting changes that affect your site.

No tracking pixels, and one click to leave.

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.