88

The time on my system is incorrect for some reason.
i need to run an update but i can't seem to be able to
this is the errror.

ntpdate pool.ntp.org
31 Aug 12:31:59 ntpdate[3108]: the NTP socket is in use, exiting

i just rebooted, i do not know how anything can be in use.

4 Answers 4

94

It's in use because the ntp service is probably running. You did not mention which Linux you are using so this assumes you have service installed (that you are running a System V system):

$ sudo ntpdate pool.ntp.org
31 Aug 19:05:55 ntpdate[8911]: the NTP socket is in use, exiting
$ sudo service ntp stop
[ ok ] Stopping NTP server: ntpd.
$ sudo ntpdate pool.ntp.org
31 Aug 19:07:11 ntpdate[10355]: adjust time server 46.29.176.115 offset -0.002893 sec
$ sudo service ntp start
4
  • 13
    For people reading the way above, though it technically works, look below at superuser.com/a/639516/308927 because it's way simpler (single command, no need to twiddle with stopping/starting the service). Apr 1, 2015 at 6:59
  • 1
    Wouldn't stop for me, so I force stopped it and the started it. sudo pkill -9 -f ntp. That did the trick on centOS for me.
    – radtek
    Apr 8, 2016 at 21:16
  • 1
    In my case (SL), the service name wasn't ntp, but service ntpd stop
    – Werner
    Jun 3, 2016 at 23:56
  • 1
    I obtain this error message: 26 Jan 10:52:30 ntpdate[4093]: no server suitable for synchronization found
    – nightcod3r
    Jan 26, 2017 at 8:49
178

If you want to execute ntpdate with the ntp daemon already up and running, use the following command:

# ntpdate -u pool.ntp.org

and it will use a different port.

1
  • 11
    This should be the accepted answer. It's just one command, so it's a great time saver. It worked for me and fixed a multi-hour clock skew. I wish I knew it before.
    – proski
    Dec 22, 2015 at 17:17
3

Simple one-liner to sync your clock:

ntpdate -u ptbtime1.ptb.de && hwclock -w
1
  • Syncing your clock is only half of keeping time. The other half is keeping your clock synced long term. ...But thanks for your answer because it gave me more ideas to chew on. The hwclick man page says that most systems update the hwclock when they shutdown and read it when they boot up. Otherwise it's not used. It only provides accuracy up to the second. (But I also suspect it might be used to track drift and as part of this it would get updated from time to time.) Mar 24, 2018 at 12:04
1

You could have a firewall blocking port 123 which can cause the ntp server to never see time servers.

In my case my ISP (Internet Service Provider) was blocking ports.

A port scan of 123 didn't detect the blockage either.

The smoking gun was that I temporarily have two independent, internet feeds. In linux if I run ntpq -p (repeatedly) with the first internet feed hooked up nothing gets updated, but with the other feed I get updates!

As @Jens A. Koch says, ntpdate -u <server name> does go around this, well, temporarily (no pun intended), it does not fix the time issue long term.

Over time drift will occur in both your system and hardware clocks. Also in my case dual booting linux/windows causes the hardware clock to further get messed up (by hours).

So you must have port 123 open for UDP for to maintain your system clock.


Rather than using -u, you can also do this which I think uses port 123 (rather than a non 'privileged' port):

service ntp stop, then
ntpdate <server url> (without the -u) and finally
service ntp start.

This seems to bypass the port blockage issue, at least to set the clock one time. If -u works, but this does not, then it's a pretty sure sign that the port is blocked, or the server is unresponsive, ...


Another issue that I had to solve was that for me the Debian default /etc/ntp.conf configuration included 4 lines to the pools: debian.pool.ntp.org. None of those servers worked. I got this error message:

Error resolving debian.pool.ntp.org: No address associated with
hostname (-5) 24 Mar 04:49:27 ntpdate[15115]: Can't find host
debian.pool.ntp.org: No address associated with hostname (-5) 24 Mar
04:49:27 ntpdate[15115]: no servers can be used, exiting

I had to change the servers to us.pool.ntp.org.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.