Fix "ntpdate: the NTP socket is in use, exiting" on Linux
ntpdate fails with "the NTP socket is in use, exiting" because a time daemon already holds UDP port 123. Find it, then either stop it for a one-time sync, run ntpdate -u, or let ntpd, chrony or timesyncd do the job.
ntpdate[21718]: the NTP socket is in use, exiting means another program already has UDP port 123 open, and ntpdate wants that same port to send its query. Almost always the "other program" is the NTP daemon itself (ntpd or ntpsec). You have three ways out: run ntpdate -u so it uses a different port, stop the daemon for a moment, or skip ntpdate and let the daemon do the sync.
The fastest fix that works on any distro that still ships ntpdate:
sudo ntpdate -u pool.ntp.org
The rest of this page explains why it happens, which fix I would pick, and what to use instead on Debian 12/13 and Ubuntu 24.04, where ntpdate is a leftover.
Why ntpdate can't get the socket
Classic ntpdate sends its request from the privileged NTP port, UDP 123. Only one process can bind that port. If ntpd is running, it got there first, so ntpdate gives up with "the NTP socket is in use, exiting".
This is common in two situations:
- You installed the
ntppackage (which startsntpd) and still have an old cron job or script that calls ntpdate. - You're on a server where someone set up both ntpd and an hourly
ntpdate"just to be sure". The two fight over the port.
Check what actually owns the port before changing anything:
sudo ss -ulpn 'sport = :123'
You'll see something like users:(("ntpd",pid=812,fd=20)). If ss isn't there, sudo lsof -i UDP:123 gives the same answer.
If the list is empty, nothing holds port 123 and the error should not come back. Run ntpdate again.
Fix 1: use an unprivileged port with ntpdate -u
The -u flag tells ntpdate to send from a high, unprivileged port instead of 123. The port conflict disappears and the daemon keeps running:
sudo ntpdate -u pool.ntp.org
If you only want to see the offset without touching the clock, use -q:
ntpdate -q pool.ntp.org
One thing to keep in mind. When ntpd is running and you step the clock behind its back with ntpdate, the daemon has to deal with the jump. It copes, but it's not how the tools are meant to work together. For a one-off check it's fine. In a cron job it isn't (see Fix 3).
Fix 2: stop the daemon, sync, start it again
This is the old-school approach. It makes sense when the clock is far off, for example after a VM was restored from a snapshot or the hardware clock battery died.
On a systemd distro with the classic ntp package:
sudo systemctl stop ntp
sudo ntpdate pool.ntp.org
sudo systemctl start ntp
Debian 12 and 13 ship the daemon from NTPsec, and there the service is called ntpsec:
sudo systemctl stop ntpsec
sudo ntpdate pool.ntp.org
sudo systemctl start ntpsec
RHEL, CentOS and Fedora with the old ntp package call the unit ntpd. Not sure about the name? systemctl list-units | grep -i ntp will tell you.
Fix 3: let the daemon do the sync
If ntpd is already running, you don't need ntpdate at all. ntpd can do a one-shot sync itself and then exit:
sudo systemctl stop ntp # or ntpsec / ntpd
sudo ntpd -gq
sudo systemctl start ntp
-g allows a large first correction (by default ntpd refuses offsets over 1000 seconds) and -q sets the time once and quits.
My rule: if you have a cron job calling ntpdate on a box that also runs ntpd, delete the cron job. The daemon already keeps the clock in sync, and the cron job is what keeps throwing this error into your logs.
What to use instead of ntpdate on modern Debian and Ubuntu
ntpdate is deprecated, and the package names changed under it:
- On Debian 12 and 13, the
ntpdatepackage is only a transitional package that pulls inntpsec-ntpdate, the NTPsec version of the tool. - Ubuntu doesn't use ntpd by default anymore. Recent releases use
systemd-timesyncdor chrony, and Ubuntu's own docs point ntpdate users to chrony for one-shot syncs.
So on a current system the right question is usually not "how do I make ntpdate work" but "which time service do I have". Check:
timedatectl
Look at System clock synchronized and NTP service. Then pick the matching command below.
systemd-timesyncd
timesyncd uses a random high port as a client, so it doesn't block port 123 and won't cause this error. To make sure it's on and see its status:
sudo timedatectl set-ntp true
timedatectl timesync-status
To force a fresh sync, restart it:
sudo systemctl restart systemd-timesyncd
chrony
If chrony is running, ask it to step the clock right now:
sudo chronyc makestep
chronyc tracking
For the real ntpdate replacement (set the time once and exit), stop the service first, then run chronyd in one-shot mode:
sudo systemctl stop chrony # chronyd on RHEL/Fedora
sudo chronyd -q 'server pool.ntp.org iburst'
sudo systemctl start chrony
chronyd -Q with a capital Q only prints the offset and leaves the clock alone, the same idea as ntpdate -q.
As a plain client, chrony normally doesn't listen on port 123. If ss shows chronyd on 123, the box is set up as an NTP server (there's an allow line in chrony.conf), and ntpdate without -u will fail there too.
Don't run two time daemons
If ss shows both ntpd and chronyd, or you have ntpd plus timesyncd enabled, pick one and disable the rest. Two daemons correcting the same clock is how you end up with drift that nobody can explain. On a typical server:
sudo systemctl disable --now ntp ntpsec 2>/dev/null
sudo systemctl enable --now chrony
Swap the names around if you prefer to keep ntpd. If you need a reliable upstream to point it at, I keep a list of public NTP time servers. And if you want this machine to serve time to your LAN, there's a separate guide on setting up an NTP server on CentOS 8 with chrony.
FAQ
Is "the NTP socket is in use, exiting" dangerous?
No. ntpdate just refused to run. Your clock wasn't changed, and the daemon that holds the port is usually already keeping time correct. Check with timedatectl or ntpq -p.
What does ntpdate -u do?
It makes ntpdate send from an unprivileged source port instead of UDP 123. That avoids the conflict with a running ntpd. It's also useful when a firewall blocks outgoing traffic from port 123.
Can I just kill ntpd to free the port?
You can, but stop it with systemctl stop instead of kill. That way systemd knows the service is down and you can start it cleanly again. Killing it makes systemd think it crashed, and depending on the unit it may get restarted in the middle of your ntpdate run.
Why does my cron job with ntpdate fail every hour?
Because the NTP daemon is running and holds port 123. Remove the cron job. If the clock still drifts, look at the daemon config rather than adding ntpdate back. Wrong time is also a classic cause of failed SIP registrations, see the fix for FusionPBX showing the wrong time.
ntpdate: command not found on Debian 13 or Ubuntu 24.04?
Install ntpsec-ntpdate if you really need the command, or use the native tools: timedatectl for timesyncd, chronyc makestep or chronyd -q for chrony.