107

My clock is off, so I would like to synchronize it using ntpdate. I tried several different NTP servers, but for some reason I always get the following error message:

$ sudo ntpdate ntp.ubuntu.com
4 Mar 12:27:35 ntpdate[1258]: no server suitable for synchronization found
$ sudo ntpdate pool.ntp.org
4 Mar 12:27:50 ntpdate[1267]: no server suitable for synchronization found
$ sudo ntpdate de.pool.ntp.org
4 Mar 12:28:01 ntpdate[1273]: no server suitable for synchronization found
$ sudo ntpdate us.pool.ntp.org
4 Mar 12:28:12 ntpdate[1276]: no server suitable for synchronization found

Related questions

I have looked through related questions, but none solve my problem:

Things I have tried

I installed the ntp package

...and tried using the ntpd daemon instead of the ntpdate utility. It won't sync my time either; the daemon starts fine, but my clock remains off. I even tried using the exact /etc/ntp.conf from the accepted answer in the latter post, and restarting the daemon. No go. Anyway, I don't want to use the daemon. I am perfectly aware that ntpdate is considered "deprecated", and it is advised to use ntpd -q instead. Also see here:

But since ntpd doesn't work for me either, the problem lies elsewhere. And I find that I would prefer not having to install any extra packages just for synchronizing the clock. ntpdate comes pre-installed with Ubuntu, and it should work just fine. So I uninstalled the ntp package again.

Maybe port 123 is blocked?

From this post:

...I got the idea that port 123 may be blocked from my computer / network at my work place. Indeed,

$ sudo nmap -p123 -sU -P0 localhost
...
PORT    STATE  SERVICE
123/udp closed ntp 
...
$ sudo ufw allow 123/udp
Rules updated
Rules updated (v6)
$ sudo nmap -p123 -sU -P0 localhost
...
PORT    STATE SERVICE
123/udp open  ntp
...

But still:

$ sudo ntpdate ntp.ubuntu.com
4 Mar 13:06:16 ntpdate[4361]: no server suitable for synchronization found

Even with the -u option, which tells ntpdate to use an unprivileged port for syncing (instead of port 123) which is certainly not blocked from my work place:

$ sudo ntpdate -u ntp.ubuntu.com
4 Mar 13:06:28 ntpdate[4427]: no server suitable for synchronization found

Maybe the strata are too high?

Lastly, from this post over at serverfault:

...I thought that maybe the strata from the NTP servers are too high. They aren't, though. Let's see a little more debugging info:

$ sudo ntpdate -dv ntp.ubuntu.com
 4 Mar 13:12:24 ntpdate[4523]: ntpdate [email protected] Wed Oct  9 19:08:07 UTC 2013 (1)
Looking for host ntp.ubuntu.com and service ntp
host found : golem.canonical.com
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
91.189.89.199: Server dropped: no data
91.189.94.4: Server dropped: no data
server 91.189.89.199, port 123
stratum 0, precision 0, leap 00, trust 000
refid [91.189.89.199], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time:    00000000.00000000  Mon, Jan  1 1900  1:00:00.000
originate timestamp: 00000000.00000000  Mon, Jan  1 1900  1:00:00.000
transmit timestamp:  d6c041ae.e6166441  Tue, Mar  4 2014 13:12:30.898
filter delay:  0.00000  0.00000  0.00000  0.00000 
         0.00000  0.00000  0.00000  0.00000 
filter offset: 0.000000 0.000000 0.000000 0.000000
         0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000

server 91.189.94.4, port 123
stratum 0, precision 0, leap 00, trust 000
refid [91.189.94.4], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time:    00000000.00000000  Mon, Jan  1 1900  1:00:00.000
originate timestamp: 00000000.00000000  Mon, Jan  1 1900  1:00:00.000
transmit timestamp:  d6c041af.1948fc50  Tue, Mar  4 2014 13:12:31.098
filter delay:  0.00000  0.00000  0.00000  0.00000 
         0.00000  0.00000  0.00000  0.00000 
filter offset: 0.000000 0.000000 0.000000 0.000000
         0.000000 0.000000 0.000000 0.000000
delay 0.00000, dispersion 64.00000
offset 0.000000

 4 Mar 13:12:33 ntpdate[4523]: no server suitable for synchronization found

Pfeeewww... this was a long one, sorry for that. I'm stumped. Any clues?

Update: additional infos

No matter whether an NTP server HOSTNAME figures in /etc/ntp.conf, and no matter whether the ntpd service is running or not, whenever I run sudo ntpdate -u HOSTNAME, I get no server suitable for synchronization found. Same thing when the ntpd service is not running and I omit the -u option. When the ntpd service is running and I omit the -u option, I instead get the NTP socket is in use, exiting.

Also:

$ timedatectl status
      Local time: Wed 2014-03-05 13:11:54 CET
  Universal time: Wed 2014-03-05 12:11:54 UTC
        Timezone: Europe/Berlin (CET, +0100)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2013-10-27 02:59:59 CEST
                  Sun 2013-10-27 02:00:00 CET
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2014-03-30 01:59:59 CET
                  Sun 2014-03-30 03:00:00 CEST

But the UTC time is not correct here. Right now UTC time is 11:11, not 12:11.

And:

$ sudo hwclock --show
Wed 05 Mar 2014 01:11:56 PM CET  -0.625627 seconds
4
  • you said you ran ` sudo ntpdate ntp.ubuntu.com` but did you do that after adding ntp.ubuntu.com to /etc/ntp.conf s server field? If not see the following answer
    – Stormvirux
    Mar 4, 2014 at 14:16
  • try `sudo ntpdate 0.ubuntu.pool.ntp.org
    – Stormvirux
    Mar 4, 2014 at 14:18
  • 1
    Hi, see my comment to your answer. I tried adding server pool.ntp.org to /etc/ntp.conf, but ntpdate -u pool.ntp.org throws the same error. I also tried this with ntp.ubuntu.com (adding it to /etc/ntp.conf, re-starting the ntp service, re-running ntpdate -u on the exact server I just added to /etc/ntp.conf). Summing up, it does not matter if the server I'm trying to sync with is mentioned in /etc/ntp.conf. I get the no server suitable... error in all cases (except when the ntp service is running and I omit the -u option, then I get the NTP socket in use error). Mar 4, 2014 at 16:24
  • Ok, I also tried sudo ntpdate 0.ubuntu.pool.ntp.org, which is already in the /etc/ntp.conf file. No luck - same error. Mar 4, 2014 at 16:26

5 Answers 5

71

Your hosting provider is blocking ntp packets. This heavy handed approach has been implemented by some ISPs in response to the DDoS attacks. You can see that ntpdate is sending the packets fron the ntpdate -vd :

transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)

I would contact your ISP and ask if they are blocking external ntp requests and if they have a local server that you can use for time sync.

There are a couple more obscure possibilities but it is tough to rule them out since you have not posted any logs from syslog.

11
  • 9
    You are perfectly right. It seems our university is blocking external NTP requests. It also offers a few local NTP servers as an alternative. These work perfectly. I see now that the output of ntpdate -dv should also include some receive(...) and not only transmit(...) messages. ;) Many thanks! Mar 5, 2014 at 11:30
  • One question though, how can the university block NTP packets when I use ntpdate with the -u option? Since this uses an unprivileged port instead of port 123, it means that their firewall rules must be more complex than simply "block incoming packets on port 123". So do they do some kind of deep packet inspection, then? Mar 5, 2014 at 11:42
  • 1
    They will have one firewall rule that says "Block all traffic with a destination port of 123" and then a couple of exceptions for their ntp hosts
    – dfc
    Mar 5, 2014 at 14:27
  • I had this same problem. I was able to resolve it by doing a traceroute outbound and I found a local server on the route that I was able to sync to that was running ntp. One of them was blocking it though. Thanks for the tips!
    – jonespm
    Jan 7, 2015 at 17:05
  • 1
    For me, ntpdate -vd says no servers can be used, exiting. Apr 11, 2015 at 0:45
69

This is not an ntp answer, however...

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

this and the curl version here.

6
  • 21
    This is terrible, but it works.
    – Alan Plum
    Oct 27, 2015 at 14:09
  • 9
    Feeding unsanitized data to bash command run as root? Awesome thanks for playing. This answer should be downvoted with extreme prejudice.
    – dfc
    Mar 23, 2016 at 19:26
  • 1
    Much less painful than having to deal with ISP support. Also, not critical at all if run in a local VM for test purposes.
    – Yalok Iy
    Jan 18, 2017 at 15:02
  • Can you explain me what it is doing ?
    – Suraj Jain
    Feb 2, 2017 at 6:00
  • 1
    @SurajJain Many web-servers return Date header. In that command date -s for set date, wget -S for store all headers, 2>&1 for logging errors in stdout, grep for pick line with header Date, cut for strip day of week and GMT. Z at end for treat date as UTC. Accuracy will depends of network speed. Apr 12, 2017 at 12:33
30

Use htpdate

If ntp transmission is blocked in your network, install htpdate. It syncs time over http protocol. Accuracy will be withing 0.5 secs, according to man page.

sudo apt-get install htpdate
sudo htpdate -a google.com

htpdate service will start when you install the package. Time will be update immediately if there is internet connection.

4
  • 1
    Please don't just copy and paste the same answer in every topic you find about ntp. Aug 21, 2017 at 15:30
  • 5
    Copypasta or not, this solution worked for me while I was receiving the ntpdate[22109]: no server suitable for synchronization found error.
    – kneeki
    Feb 23, 2019 at 17:26
  • 2
    in Athens,Greece feb 2021 on vodafone, only htpdate worked! thanks!!! I cannot tell how safe it is, but nothing else worked for me. Seems the ISP (Vodafone) blocks the ntp since all goes Ok but "ntp service is in use" and "no server suitable for synchronization" .., was all i was getting. Saved me from at least 30' talking to isp auto-answering etc. Feb 20, 2021 at 17:31
  • 1
    Great solution - thanks for posting! Worked for me when network prevented NTP updates ($ ntpdate -u <IP>).
    – leenremm
    Nov 7, 2021 at 18:17
13

I had the same issue and this is how I solved it. I have give a detailed answer from top to bottom. You might want to skip to middle of my answer or just refer the screenshots below for understanding it in a glance.

First install ntpdate(Obviously you have done this)

sudo apt-get install ntpdate

NEXT You need to configure ntp with servers as follows:

You should at least set following parameter in /etc/ntp.conf config file: server

For example, open /etc/ntp.conf file using nano text editor:

sudo nano /etc/ntp.conf

Locate server parameter and if it is empty set it as follows:

server pool.ntp.org

But usually In ubuntu already some servers are prewritten which might be

server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

enter image description here

Then Save the file and restart the ntpd service:

sudo /etc/init.d/ntpd start

You can synchronize the system clock to an NTP server immediately with following command:

sudo ntpdate pool.ntp.org

or just run already servers are defined

sudo ntpdate 0.ubuntu.pool.ntp.org

or other servers that are defined using server

generally

sudo ntpdate <one of the servername in /etc/ntp.conf>

BUT after that there is a chance you get the Error NTP socket in use as shown below:

enter image description here

In that case just run

ntpdate -u pool.ntp.org 

to update when ntp deamon is running

OR just stop the deamon,update and start it again as follows:

sudo ntpdate pool.ntp.org
sudo service ntp stop
sudo ntpdate pool.ntp.org
sudo service ntp start

and you will get

enter image description here

7
  • 1
    Hi, thanks for your detailed answer! Unfortunately it did not work for me. I have the /etc/ntp.conf that came along with Ubuntu, never made any changes to it. I pasted it here: pastebin.com/bB0sskzv. I also tried adding server pool.ntp.org at the top of the server list, as shown in you screenshot. Find that here: pastebin.com/YH372Jdi. With both of these setups, I ran the sequence of commands that you proposed: I added a screenshot to my original post. The result was exactly the same with both the unmodified and the modified /etc/ntp.conf. Any other ideas? Thanks! Mar 4, 2014 at 16:16
  • what does timedatectl status return
    – Stormvirux
    Mar 4, 2014 at 16:27
  • See output of the timedatectl status command in my original post. Mar 4, 2014 at 16:31
  • I have now tried with all 4 predefined servers (namely, {0..3}.ubuntu.pool.ntp.org), both with and without -u option. Always the same error. Mar 4, 2014 at 16:33
  • just tell me this one also. output of sudo hwclock --show
    – Stormvirux
    Mar 4, 2014 at 16:35
6

Similar to Alex's answer, this worked for me for getting around the ntp port being firewalled:

sudo date -s "$(curl http://s3.amazonaws.com -v 2>&1 | \
  grep "Date: " | awk '{ print $3 " " $5 " " $4 " " $7 " " $6 " GMT"}')"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .