Unable to sync date and time

When I do following commands:

$ timedatectl set-ntp off
$ timedatectl set-ntp on

All of requests gets timeout error:

$ systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
     Active: active (running) since Fri 2023-02-03 16:49:21 +0330; 7min ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 27024 (systemd-timesyn)
     Status: "Connecting to time server 178.63.52.31:123 (0.manjaro.pool.ntp.org)."
      Tasks: 2 (limit: 9406)
     Memory: 2.7M
        CPU: 117ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─27024 /usr/lib/systemd/systemd-timesyncd

Feb 03 16:54:01 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 178.63.52.50:123 (1.manjaro.pool.ntp.org).
Feb 03 16:54:12 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 217.144.138.234:123 (2.manjaro.pool.ntp.org).
Feb 03 16:54:22 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 129.70.132.35:123 (2.manjaro.pool.ntp.org).
Feb 03 16:54:32 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 141.64.5.250:123 (2.manjaro.pool.ntp.org).
Feb 03 16:54:43 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 62.108.36.235:123 (2.manjaro.pool.ntp.org).
Feb 03 16:54:53 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 88.99.76.254:123 (3.manjaro.pool.ntp.org).
Feb 03 16:55:03 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 188.40.142.18:123 (3.manjaro.pool.ntp.org).
Feb 03 16:55:13 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 85.214.46.39:123 (3.manjaro.pool.ntp.org).
Feb 03 16:55:24 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 178.215.228.24:123 (3.manjaro.pool.ntp.org).
Feb 03 16:56:38 milad-pc systemd-timesyncd[27024]: Timed out waiting for reply from 157.90.3.240:123 (0.manjaro.pool.ntp.org)

What’s the problem and how can I fix it?


More Information:

I can ping all servers without any problem, e.g.

$ ping 0.manjaro.pool.ntp.org                                                                                                                                 
PING 0.manjaro.pool.ntp.org (213.81.129.99) 56(84) bytes of data.
64 bytes from ip99.mikrocom.sk (213.81.129.99): icmp_seq=1 ttl=42 time=127 ms
64 bytes from ip99.mikrocom.sk (213.81.129.99): icmp_seq=2 ttl=42 time=129 ms

Most likely a problem with your firewall i guess :woman_shrugging:
Ping uses ICMP packets, but ntp uses different network protocol plus port…
Example:

1 Like

I don’t have any firewall but maybe ISP is blocked it :neutral_face:

How can I check it and if it is blocked by ISP what is the solution to make time work correctly? Should I modify it manually? Is it stable?

With systemd-resolved, it uses SNTP and not NTP, so incoming port 123 is not useful. It uses an ephemeral range.

You can try if you get a connection with:

nc -z -vvv -u 0.manjaro.pool.ntp.org 123

(nc is from the packages gnu-netcat or openbsd-netcat)

You could try to use the ISP’s modem as timeserver, because most also function as a proxy for that.

systemd-resolved is a different service as systemd-timesyncd :wink:

I tried your command but I couldn’t understand its results, here is the result:

$ nc -z -vvv -u 0.manjaro.pool.ntp.org 123                                ─╯
Notice: Real hostname for 0.manjaro.pool.ntp.org [78.46.53.2] is alpha.rueckgr.at
Notice: Real hostname for 0.manjaro.pool.ntp.org [49.12.132.53] is 25000-035.cloud.services.bauer-group.com
Notice: Real hostname for 0.manjaro.pool.ntp.org [164.68.124.74] is kyou.thehomeofanime.de
Notice: Real hostname for 0.manjaro.pool.ntp.org [136.243.202.118] is time01.nevondo.com
Total received bytes: 0
Total sent bytes: 0

PS: Timeouts are actually very normal when the computer has not finished fully setting up your network connection yet, see my output:

● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
     Active: active (running) since Thu 2023-02-02 09:44:23 +03; 1 day 8h ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 877 (systemd-timesyn)
     Status: "Contacted time server 185.125.190.57:123 (ntp.ubuntu.com)."
      Tasks: 2 (limit: 38273)
     Memory: 1.4M
        CPU: 268ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─877 /lib/systemd/systemd-timesyncd

[ 3224.051124] kubuntu systemd-timesyncd[877]: No network connectivity, watching for changes.
[ 3235.665093] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[ 3235.725603] kubuntu systemd-timesyncd[877]: Contacted time server 185.125.190.57:123 (ntp.ubuntu.com).
[ 6390.019791] kubuntu systemd-timesyncd[877]: No network connectivity, watching for changes.
[44326.824115] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[44326.826837] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[44327.031045] kubuntu systemd-timesyncd[877]: Contacted time server 91.189.91.157:123 (ntp.ubuntu.com).
[44853.684412] kubuntu systemd-timesyncd[877]: Timed out waiting for reply from 91.189.91.157:123 (ntp.ubuntu.com).
[44863.934297] kubuntu systemd-timesyncd[877]: Timed out waiting for reply from 91.189.94.4:123 (ntp.ubuntu.com).
[44874.184308] kubuntu systemd-timesyncd[877]: Timed out waiting for reply from 185.125.190.56:123 (ntp.ubuntu.com).
[44884.434316] kubuntu systemd-timesyncd[877]: Timed out waiting for reply from 185.125.190.57:123 (ntp.ubuntu.com).
[44894.684330] kubuntu systemd-timesyncd[877]: Timed out waiting for reply from 185.125.190.58:123 (ntp.ubuntu.com).
[45151.075894] kubuntu systemd-timesyncd[877]: Contacted time server 185.125.190.58:123 (ntp.ubuntu.com).
[46185.140756] kubuntu systemd-timesyncd[877]: No network connectivity, watching for changes.
[46188.028563] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[46189.032380] kubuntu systemd-timesyncd[877]: No network connectivity, watching for changes.
[46215.619893] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[46216.464941] kubuntu systemd-timesyncd[877]: Contacted time server 185.125.190.58:123 (ntp.ubuntu.com).
[51650.999926] kubuntu systemd-timesyncd[877]: No network connectivity, watching for changes.
[51651.001359] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[51651.063036] kubuntu systemd-timesyncd[877]: Contacted time server 185.125.190.58:123 (ntp.ubuntu.com).
[70588.793251] kubuntu systemd-timesyncd[877]: No network connectivity, watching for changes.
[70610.706602] kubuntu systemd-timesyncd[877]: Network configuration changed, trying to establish connection.
[70620.934434] kubuntu systemd-timesyncd[877]: Timed out waiting for reply from 185.125.190.58:123 (ntp.ubuntu.com).
[70620.996037] kubuntu systemd-timesyncd[877]: Contacted time server 185.125.190.57:123 (ntp.ubuntu.com).

Thank you for informing about Timeouts.
I figured it out, it seems government is blocked ntp service port because after using a VPN, I was able to sync time and date quickly and without any problem.

But I still have another question: How can I prevent the changing date and time after reboot? because each time I reboot, the time is wrong again.

That depends on “in what way” it is wrong…

  • If it starts at like 1970 then your RTC-Battery in your computer needs to be replaced. (Also known as CMOS Battery)
  • If it is just showing wrong timezone you can set that using timedatectl, see it’s man page…
  • If it is showing correct timezone but is shifted a few hours, you will need to change your setting of “RTC in local TZ” using the same command as above.
1 Like

It is not because of CMOS Battery because this problem is occurring after daylight. Also it is always one hour before.
Also I checked the timezone and it is correct:

$ timedatectl                                                                                                                                                     l
               Local time: Fri 2023-02-03 19:07:36 +0330
           Universal time: Fri 2023-02-03 15:37:36 UTC
                 RTC time: Fri 2023-02-03 15:37:36
                Time zone: Asia/Tehran (+0330, +0330)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Check what i added to my reply at same time you posted your reply :slight_smile:

               Local time: Fri 2023-02-03 18:41:16 +03
           Universal time: Fri 2023-02-03 15:41:16 UTC
                 RTC time: Fri 2023-02-03 15:41:16
                Time zone: Europe/Istanbul (+03, +0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Mine stays correct because i use UTC time in the BIOS, and not my local time…

Keep in mind that if you dual boot using Micro$@$, it will bug your RTC time, because one uses UTC as system time and the other uses Local time by default…

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.