RaspberryPi NTP server messed by node red?

Here is the description of my system:
I have an ESP32 which connect to a Raspberry Pi configured as an access point.
On my raspberry pi i have a NTP server : I installed ntpd and i modify the ntpd.conf to add the lines:

server prefer 
fudge stratum 12

on my Esp32, I use the library NTPClient.h (GitHub - WhymustIhaveaname/NTPClient: Connect to a NTP server which is a forked that provide milliseconds). The NTP updates are "overkill" for debuging: every 5 seconds, and then display the time every 10ms.

I am keeping developing my system which would require MQTT. Therefore I am using Node-Red.
For now, my simple code does not have any MQTT connection, just sending/receiving NTP paquets.

The issue:
I run the code for few minutes, and I get the real time.
After few minute, i launch node-red, and once everything is properly loaded, the NTP update is completely messed up.

sent ntp packet
got ntp packet.
tik, tok, (tok-tik)/2: 347774, 347794, 10.00
receive_int, transmit_int: 0, 0
receive_dec, transmit_dec: 0, 0.000000, 0, 0.000000
current Epoc: 2085978496 0.010000

I did the test few times, and each time the updated times is exactly 06:28:16, it increases to 06:28:26, then reset to 06:28:16

The main issue: on the boot
If node red is launched the first NTP request provide always the same time: 04:39:39 which is later updated to 06:28:16

Are you aware of a potential interaction between node-red and the ntp server?

Thank you

The first thing that gets my attention is the IP address.

127.x.x.x is for local use only and no other machine can use them.

Try an IP address which is part of the range used by the WAP.

Thanks, sorry I was wrong with node-red causing issues. I am not sure if this is the right forum then.
I changed the IP address to (my AP is on, and release Ip adress from to . Is it the correct choice, or should I set it tp


OK, I just typed:

sudo service ntp restart

and it solved the issue (till when?). Any specialist on this?

After few tests decreasing the request time down to 100ms, I confirm the issues are caused by the too small time allowed for the NTP update.

ntp queries are normally done in a timescale of seconds not ms. Doing queries that fast risks flooding the server.

Also if you really need extra accuracy, you need to configure multiple ntp servers and have them also sync externally of course. A minimum of 3 or 4 seems to be the recommendation.

You can make it the same IP address as the AP.

IP numbers are not ..... limited to what you can have on them.
So your access point can also be the NTP server.

But you can't have two respberry pies with the same IP.

As to which IP address, well, you could also use DHCP, but I would suggest having a fixed one.

Thank you so much,
I used the sparkfun tutorial to setup my AP. I am quite a newbie with all these things but finally converging towards some solution.

@TotallyInformation: do you think I could modify my ntpd.conf as follow:

server prefer
server prefer 
server prefer 
server prefer 
fudge stratum 12
fudge stratum 12
fudge stratum 12
fudge stratum 12

my NTPClient function on my esp32 will remain the same:
NTPClient timeClient(ntpUDP, " ", 0, 1800000);//one request every 30min

Sorry, I'm no expert on NTP I'm afraid. You would need to do some searching to find the best setup. You need to set up a hierarchy of internal and external NTP servers with the external servers referencing one of the "pool" servers so that they get load balanced. You also need to make sure that you aren't hitting external NTP servers too often or you will probably get banned (it is, after all, a free service).

Frankly, I use the default settings for my OS (Debian/Rasbian) to set my servers timesync. For my ESP devices, I use an NTP library (or whatever is built into ESPEasy or Tasmota if I'm using those firmwares) and also set them to use external NTP. As I'm in the UK, I use the UK pool server. This is sufficient for me and I've never had to worry about time but I'm certainly not trying to look for ms time sync. As long as my times are accurate to the second, that is plenty for me.

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