Inject nodes not firing on boot up of Raspberry Pi 4

I seem to be having a major brain issue with Inject nodes of all things.
I have a simple inject node set to fire after 0.1 seconds . All it does it trigger an Exec node that simply issues a hostname -I in order to get the IP address which it then displays in a Text node.

If I Deploy a change, it fires immediately and the IP address is displayed.
If I reboot the Raspberry Pi, the inject node never fires - till such time as I manually click the inject node to force it..
I have a debug node on the output of the Inject and on the output of the Exec. I have bumped the Inject once after timer to 3 seconds thinking it needed time to get up and running but still nothing.

Further info after delving into this some more.

Node Red is auto started on the Raspberry Pi by this command:
sudo systemctl enable nodered.service

Inject nodes do not get fired when node red is auto started in this manner.

However, I then used SSH into the PI and I enter:
node-red-restart
This then did indeed get the inject nodes to fire up but I had to start at 0.5 sec and stagger them.

So something is definitely amiss here. I have minimal software installed. Raspberry Pi headless, Nodered, Mosquito MQTT and that's about it.

Any clues or suggestions?

How big is the flow you are loading ? What other nodes is it loading ? are the injects on the first tab ? (as the flow file gets read and initialised in order)

Configure the output of the inject node to write to the system log. Then reboot and look in /var/log/syslog to see what is there. Show us what you see starting with the Welcome to node-red message.

Just start it after 2 seconds instead of 0.1.
This should be fast enough.

I have 4 tabs currently in development. These are in 2 Flows.
1 tab has 9 nodes
The other tab has 44 nodes.
So to narrow this down - I disabled the second flow with the 44 nodes and rebooted.
This leaves just 9 nodes.
The 9 flow tab didn't fire the inject node which was set at 0.5 seconds.
I tried again with 2 seconds and rebooted.

Here are some logs of my test with just 9 nodes.
pi@raspberrypi:~ node-red-log** **pi@raspberrypi:~ node-red-log

25 Jul 07:27:05 - [info] Node-RED version: v1.1.0
25 Jul 07:27:05 - [info] Node.js version: v12.18.3
25 Jul 07:27:05 - [info] Linux 4.19.118-v7l+ arm LE
25 Jul 07:27:06 - [info] Loading palette nodes
25 Jul 07:27:08 - [info] Dashboard version 2.22.1 started at /ui
25 Jul 07:27:08 - [info] Settings file : /home/pi/.node-red/settings.js
25 Jul 07:27:08 - [info] Context store : 'default' [module=memory]
25 Jul 07:27:08 - [info] Context store : 'storeInFile' [module=localfilesystem]
25 Jul 07:27:08 - [info] User directory : /home/pi/.node-red
25 Jul 07:27:08 - [warn] Projects disabled : editorTheme.projects.enabled=false
25 Jul 07:27:08 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
25 Jul 07:27:08 - [info] Server now running at http://127.0.0.1:1880/
25 Jul 07:27:08 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
25 Jul 07:27:08 - [info] Starting flows
25 Jul 07:27:08 - [info] Started flows
25 Jul 07:27:10 - [info] [debug:275c17e7.b56a08] 1595687230828

and the log from var/log/syslog

Jul 25 07:27:05 raspberrypi Node-RED[333]: Welcome to Node-RED
Jul 25 07:27:05 raspberrypi Node-RED[333]: ===================
Jul 25 07:27:05 raspberrypi Node-RED[333]: 25 Jul 07:27:05 - [info] Node-RED version: v1.1.0
Jul 25 07:27:05 raspberrypi Node-RED[333]: 25 Jul 07:27:05 - [info] Node.js version: v12.18.3
Jul 25 07:27:05 raspberrypi Node-RED[333]: 25 Jul 07:27:05 - [info] Linux 4.19.118-v7l+ arm LE
Jul 25 07:27:05 raspberrypi systemd[1]: systemd-rfkill.service: Succeeded.
Jul 25 07:27:06 raspberrypi Node-RED[333]: 25 Jul 07:27:06 - [info] Loading palette nodes
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Dashboard version 2.22.1 started at /ui
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Settings file : /home/pi/.node-red/settings.js
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Context store : 'default' [module=memory]
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Context store : 'storeInFile' [module=localfilesystem]
Jul 25 07:27:08 raspberrypi dhcpcd[346]: wlan0: carrier acquired
Jul 25 07:27:08 raspberrypi dhcpcd[346]: wlan0: connected to Access Point `cheshire'
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] User directory : /home/pi/.node-red
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [warn] Projects disabled : editorTheme.projects.enabled=false
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
Jul 25 07:27:08 raspberrypi dhcpcd[346]: wlan0: IAID 32:7c:55:96
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Server now running at http://127.0.0.1:1880/
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [warn]
Jul 25 07:27:08 raspberrypi Node-RED[333]: ---------------------------------------------------------------------
Jul 25 07:27:08 raspberrypi Node-RED[333]: Your flow credentials file is encrypted using a system-generated key.
Jul 25 07:27:08 raspberrypi Node-RED[333]: If the system-generated key is lost for any reason, your credentials
Jul 25 07:27:08 raspberrypi Node-RED[333]: file will not be recoverable, you will have to delete it and re-enter
Jul 25 07:27:08 raspberrypi Node-RED[333]: your credentials.
Jul 25 07:27:08 raspberrypi Node-RED[333]: You should set your own key using the 'credentialSecret' option in
Jul 25 07:27:08 raspberrypi Node-RED[333]: your settings file. Node-RED will then re-encrypt your credentials
Jul 25 07:27:08 raspberrypi Node-RED[333]: file using your chosen key the next time you deploy a change.
Jul 25 07:27:08 raspberrypi Node-RED[333]: ---------------------------------------------------------------------
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Starting flows
Jul 25 07:27:08 raspberrypi Node-RED[333]: 25 Jul 07:27:08 - [info] Started flows
Jul 25 07:27:09 raspberrypi kernel: [ 12.297669] Bluetooth: Core ver 2.22
Jul 25 07:27:09 raspberrypi kernel: [ 12.297713] NET: Registered protocol family 31
Jul 25 07:27:09 raspberrypi kernel: [ 12.297717] Bluetooth: HCI device and connection manager initialized
Jul 25 07:27:09 raspberrypi kernel: [ 12.297734] Bluetooth: HCI socket layer initialized
Jul 25 07:27:09 raspberrypi kernel: [ 12.297741] Bluetooth: L2CAP socket layer initialized
Jul 25 07:27:09 raspberrypi kernel: [ 12.297760] Bluetooth: SCO socket layer initialized
Jul 25 07:27:09 raspberrypi kernel: [ 12.307406] Bluetooth: HCI UART driver ver 2.3
Jul 25 07:27:09 raspberrypi kernel: [ 12.307413] Bluetooth: HCI UART protocol H4 registered
Jul 25 07:27:09 raspberrypi kernel: [ 12.307455] Bluetooth: HCI UART protocol Three-wire (H5) registered
Jul 25 07:27:09 raspberrypi kernel: [ 12.307558] Bluetooth: HCI UART protocol Broadcom registered
Jul 25 07:27:09 raspberrypi btuart[356]: bcm43xx_init
Jul 25 07:27:09 raspberrypi btuart[356]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
Jul 25 07:27:09 raspberrypi btuart[356]: Set Controller UART speed to 3000000 bit/s
Jul 25 07:27:09 raspberrypi btuart[356]: Device setup complete
Jul 25 07:27:09 raspberrypi systemd[1]: Starting Load/Save RF Kill Switch Status...
Jul 25 07:27:09 raspberrypi systemd[1]: Started Configure Bluetooth Modems connected by UART.
Jul 25 07:27:09 raspberrypi systemd[1]: Started Load/Save RF Kill Switch Status.
Jul 25 07:27:09 raspberrypi systemd[1]: Starting Bluetooth service...
Jul 25 07:27:09 raspberrypi systemd[1]: Created slice system-bthelper.slice.
Jul 25 07:27:09 raspberrypi bluetoothd[517]: Bluetooth daemon 5.50
Jul 25 07:27:09 raspberrypi systemd[1]: Started Bluetooth service.
Jul 25 07:27:09 raspberrypi systemd[1]: Reached target Bluetooth.
Jul 25 07:27:09 raspberrypi systemd[1]: Started Raspberry Pi bluetooth helper.
Jul 25 07:27:09 raspberrypi bluetoothd[517]: Starting SDP server
Jul 25 07:27:09 raspberrypi kernel: [ 12.454050] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Jul 25 07:27:09 raspberrypi kernel: [ 12.454056] Bluetooth: BNEP filters: protocol multicast
Jul 25 07:27:09 raspberrypi kernel: [ 12.454066] Bluetooth: BNEP socket layer initialized
Jul 25 07:27:09 raspberrypi bluetoothd[517]: Bluetooth management interface 1.14 initialized
Jul 25 07:27:09 raspberrypi dbus-daemon[332]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.5' (uid=0 pid=517 comm="/usr/lib/bluetooth/bluetoothd ")
Jul 25 07:27:09 raspberrypi systemd[1]: Starting Hostname Service...
Jul 25 07:27:09 raspberrypi bluetoothd[517]: Sap driver initialization failed.
Jul 25 07:27:09 raspberrypi bluetoothd[517]: sap-server: Operation not permitted (1)
Jul 25 07:27:09 raspberrypi bthelper[518]: Changing power off succeeded
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 Powered: yes
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 Alias: BlueZ 5.50
Jul 25 07:27:09 raspberrypi bthelper[518]: [#033[0;93mCHG#033[0m] Controller DC:A6:32:7C:55:97 Pairable: yes
Jul 25 07:27:09 raspberrypi bthelper[518]: Changing power on succeeded
Jul 25 07:27:09 raspberrypi systemd[1]: bthelper@hci0.service: Succeeded.
Jul 25 07:27:09 raspberrypi dhcpcd[346]: wlan0: rebinding lease of 192.168.1.21
Jul 25 07:27:09 raspberrypi dbus-daemon[332]: [system] Successfully activated service 'org.freedesktop.hostname1'
Jul 25 07:27:09 raspberrypi systemd[1]: Started Hostname Service.
Jul 25 07:27:09 raspberrypi dhcpcd[346]: wlan0: soliciting an IPv6 router
Jul 25 07:27:10 raspberrypi dhcpcd[346]: wlan0: probing address 192.168.1.21/24
Jul 25 07:27:10 raspberrypi Node-RED[333]: 25 Jul 07:27:10 - [info] [debug:275c17e7.b56a08] 1595687230828
Jul 25 07:27:14 raspberrypi systemd[1]: systemd-rfkill.service: Succeeded.
Jul 25 07:27:15 raspberrypi dhcpcd[346]: wlan0: leased 192.168.1.21 for 86400 seconds
Jul 25 07:27:15 raspberrypi avahi-daemon[335]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.21.
Jul 25 07:27:15 raspberrypi avahi-daemon[335]: New relevant interface wlan0.IPv4 for mDNS.
Jul 25 07:27:15 raspberrypi avahi-daemon[335]: Registering new address record for 192.168.1.21 on wlan0.IPv4.
Jul 25 07:27:15 raspberrypi dhcpcd[346]: wlan0: adding route to 192.168.1.0/24
Jul 25 07:27:15 raspberrypi dhcpcd[346]: wlan0: adding default route via 192.168.1.1
Jul 25 07:27:15 raspberrypi dhcpcd[346]: forked to background, child pid 580
Jul 25 07:27:15 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
Jul 25 07:27:15 raspberrypi systemd[1]: Reached target Network.
Jul 25 07:27:15 raspberrypi systemd[1]: Starting OpenBSD Secure Shell server...
Jul 25 07:27:15 raspberrypi systemd[1]: Reached target Network is Online.
Jul 25 07:27:15 raspberrypi systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
Jul 25 07:27:15 raspberrypi systemd[1]: Condition check resulted in fast remote file copy program daemon being skipped.
Jul 25 07:27:15 raspberrypi systemd[1]: Starting Permit User Sessions...
Jul 25 07:27:15 raspberrypi systemd[1]: Starting /etc/rc.local Compatibility...
Jul 25 07:27:15 raspberrypi systemd[1]: Started /etc/rc.local Compatibility.
Jul 25 07:27:15 raspberrypi systemd[1]: Started Permit User Sessions.
Jul 25 07:27:15 raspberrypi systemd[1]: Started Getty on tty1.
Jul 25 07:27:15 raspberrypi systemd[1]: Reached target Login Prompts.
Jul 25 07:27:15 raspberrypi systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.
Jul 25 07:27:15 raspberrypi systemd[1]: Started OpenBSD Secure Shell server.
Jul 25 07:27:15 raspberrypi systemd[1]: Reached target Multi-User System.
Jul 25 07:27:15 raspberrypi systemd[1]: Starting Update UTMP about System Runlevel Changes...
Jul 25 07:27:15 raspberrypi systemd[1]: systemd-update-utmp-runlevel.service: Succeeded.
Jul 25 07:27:15 raspberrypi systemd[1]: Started Update UTMP about System Runlevel Changes.
Jul 25 07:27:15 raspberrypi systemd[1]: Startup finished in 1.044s (kernel) + 17.815s (userspace) = 18.859s.
Jul 25 07:27:15 raspberrypi systemd[1]: Created slice User Slice of UID 1000.
Jul 25 07:27:15 raspberrypi systemd[1]: Starting User Runtime Directory /run/user/1000...
Jul 25 07:27:15 raspberrypi systemd[1]: Started User Runtime Directory /run/user/1000.
Jul 25 07:27:15 raspberrypi systemd[1]: Starting User Manager for UID 1000...
Jul 25 07:27:16 raspberrypi systemd[596]: Listening on GnuPG cryptographic agent and passphrase cache.
Jul 25 07:27:16 raspberrypi systemd[596]: Listening on GnuPG network certificate management daemon.
Jul 25 07:27:16 raspberrypi systemd[596]: Reached target Paths.
Jul 25 07:27:16 raspberrypi systemd[596]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jul 25 07:27:16 raspberrypi systemd[596]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jul 25 07:27:16 raspberrypi systemd[596]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jul 25 07:27:16 raspberrypi systemd[596]: Reached target Sockets.
Jul 25 07:27:16 raspberrypi systemd[596]: Reached target Timers.
Jul 25 07:27:16 raspberrypi systemd[596]: Reached target Basic System.
Jul 25 07:27:16 raspberrypi systemd[596]: Reached target Default.
Jul 25 07:27:16 raspberrypi systemd[596]: Startup finished in 133ms.
Jul 25 07:27:16 raspberrypi systemd[1]: Started User Manager for UID 1000.
Jul 25 07:27:16 raspberrypi systemd[1]: Started Session c1 of user pi.
Jul 25 07:27:31 raspberrypi systemd[1]: systemd-fsckd.service: Succeeded.
Jul 25 07:27:44 raspberrypi systemd-timesyncd[291]: Synchronized to time server for the first time 133.243.238.243:123 (2.debian.pool.ntp.org).
Jul 25 07:27:45 raspberrypi systemd[1]: Started Session c2 of user pi.
Jul 25 07:27:52 raspberrypi systemd[1]: systemd-hostnamed.service: Succeeded.
pi@raspberrypi:/var/log $

Does not the log show that the inject node is firing correctly?

The line I highlighted does appear so. Yet the output display node isn't displaying the result. I am putting in another debug at the exec node and the output node. Maybe the exec isn't completing before the display occurs. Yet it works if I trigger manually...

One of the other nodes may be trying to use a system resource that is not yet available. Give the debug nodes names then you will more easily see what is happening.

I put some node.warn statements in and here are the results:

The first is after a boot up. The text from the node.warn appears as "Exec completed" but the second line displaying the msg.payload is blank.

The second test is after I trigger the inject node manually

On Boot up
Jul 25 08:47:36 raspberrypi Node-RED[339]: 25 Jul 08:47:36 - [info] [debug:275c17e7.b56a08] 1595692056156
Jul 25 08:47:36 raspberrypi Node-RED[339]: 25 Jul 08:47:36 - [info] [debug:9c47416f.8a5da]
Jul 25 08:47:36 raspberrypi Node-RED[339]: 25 Jul 08:47:36 - [warn] [function:b800d823.2bdac8] Exec completed
Jul 25 08:47:36 raspberrypi Node-RED[339]: 25 Jul 08:47:36 - [warn] [function:b800d823.2bdac8]

Trigger manually

Jul 25 08:50:29 raspberrypi Node-RED[339]: 25 Jul 08:50:29 - [info] [debug:275c17e7.b56a08] 1595692229461
Jul 25 08:50:29 raspberrypi Node-RED[339]: 25 Jul 08:50:29 - [info] [debug:9c47416f.8a5da]
Jul 25 08:50:29 raspberrypi Node-RED[339]: 192.168.1.21
Jul 25 08:50:29 raspberrypi Node-RED[339]: 25 Jul 08:50:29 - [warn] [function:b800d823.2bdac8] Exec completed
Jul 25 08:50:29 raspberrypi Node-RED[339]: 25 Jul 08:50:29 - [warn] [function:b800d823.2bdac8] 192.168.1.21

So it appears that the exec of command 'hostname -I' is not finishing before it gets passed to the next node.

I think that is unlikely. Export those few nodes and post here (use the </> button and paste the flow in).

[Edit] Did you install using the pi script from the node red docs or did you write the service file yourself (or get it from elsewhere)? If not from the node-red recommended script then post the service file here also.

This was all installed by the book. I followed the Node Red install instructions. I'm not a Unix guy!
3 nodes - Inject, Exec and Text output. The others are there just for diagnostics

[{"id":"5175483e.461228","type":"exec","z":"60589787.0597e8","command":"hostname -I","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"hostname","x":240,"y":240,"wires":[["9c47416f.8a5da","b800d823.2bdac8"],[],[]]},{"id":"1f586ecb.fa8ab1","type":"inject","z":"60589787.0597e8","name":"get ip","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":91,"y":239.5,"wires":[["5175483e.461228","275c17e7.b56a08"]]},{"id":"bd2447e6.5567b8","type":"ui_text","z":"60589787.0597e8","group":"2715539f.3da89c","order":1,"width":0,"height":0,"name":"","label":"Pi Local IP Address","format":"{{msg.payload}}","layout":"col-center","x":630,"y":240,"wires":[]},{"id":"275c17e7.b56a08","type":"debug","z":"60589787.0597e8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":260,"y":180,"wires":[]},{"id":"9c47416f.8a5da","type":"debug","z":"60589787.0597e8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":180,"wires":[]},{"id":"b800d823.2bdac8","type":"function","z":"60589787.0597e8","name":"","func":"node.warn(\"Exec completed \");\nnode.warn(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":240,"wires":[["bd2447e6.5567b8"]]},{"id":"2715539f.3da89c","type":"ui_group","z":"","name":"Raspberry Pi","tab":"980cfeef.05cc1","order":1,"disp":true,"width":"6","collapse":false},{"id":"980cfeef.05cc1","type":"ui_tab","z":"","name":"Raspberry Pi","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

Add into the function node a warn showing msg.rc and add another debug node on output 2 of the exec node.

Actually, you can see what is happening if you look back at your syslog. Notice that the wifi connection is not made until five seconds after your debug node fires, so when you call hostname it has not yet connected so there are no ip addresses.
Did you try a large delay on the inject node? Large enough to make sure the wifi is connected? Ten seconds maybe, though potentially it could even be longer than that. Also if you have a power fail and the pi and router both power up at the same time the router might take much longer to startup than the pi. Perhaps you need to modify your flow so that it refreshes every minute.

This possibly

image

[{"id":"c9f17e8.fb093","type":"inject","z":"bdd7be38.d3b55","name":"get ip","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":151,"y":1499.5,"wires":[["1edd870e.802221","bcc4beae.624c8"]]},{"id":"1edd870e.802221","type":"exec","z":"bdd7be38.d3b55","command":"hostname -I","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"hostname","x":300,"y":1500,"wires":[["24bf71c5.84bdee","11105f53.e63fa1","3df13dda.ac91ca"],[],[]]},{"id":"11105f53.e63fa1","type":"function","z":"bdd7be38.d3b55","name":"","func":"node.warn(\"Exec completed \");\nnode.warn(msg.payload);\nnode.warn(msg.rc)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":1500,"wires":[[]]},{"id":"3df13dda.ac91ca","type":"switch","z":"bdd7be38.d3b55","name":"Empty?","property":"payload","propertyType":"msg","rules":[{"t":"empty"}],"checkall":"true","repair":false,"outputs":1,"x":240,"y":1600,"wires":[["33dcdde2.1826aa"]]},{"id":"33dcdde2.1826aa","type":"trigger","z":"bdd7be38.d3b55","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":390,"y":1600,"wires":[["1edd870e.802221"]]}]

Thanks Colin.
I hadn't twigged that the wifi hadn't completed startup. I will try your suggested loop and get back to you.
(Mainframe Assembler is so much easier!)

Hmm, not sure about that. Though it must be 30 years since I did any assembler.

I changed the inject delay to 4 seconds and added the check of msg.payload.length in a loop as you suggested with a wait of 500ms. It now works fine and runs round the loop a few times.
Although in my mind it's a bit of a workaround.
However my Linux skills are not up to working out how to address it differently.
Ideally, I would prefer to have Node Red wait on starting up until essential dependencies have themselves completed startup. Wifi, MQTT etc. (Yes, I know - what is deemed essential dependencies!)

Thanks for the help on this.

It can be done in the systemd startup script, but isn't trivial. If you really want to do it then a bit of googling will give you some suggestions. It couldn't be part of the standard script as, for example, not every system is necessarily even connected to a network.

Yes indeed. Looking into it to see what is involved. Thanks for the fix.