Skip to Content

Node-RED not starting after a reboot? 6 checks

Short answer: when Node-RED runs when you start it by hand but not after a reboot, the flows are usually still on the device. Check that it runs as an enabled service, which user it runs as, which flows file it opens, the missing nodes, the network at boot and the log, in this order.

Download the checklist (PDF, 2 pages)

Descarga la lista de comprobación (PDF, 2 páginas)

These checks apply to Node-RED installed with the official script on Raspberry Pi OS or Debian, on any Linux device: Raspberry PLC, panel PCs, gateways and edge computers. Before you change anything, copy the whole user directory (flows, credentials, settings.js and package.json). If the editor comes up empty after a power cut, the cause can be a corrupted file system: start with the lesson on SD cards in the field.

Six checks, in this order

CheckWhat to doGood result
1. ServiceStarted from a terminal with node-red, it does not come back after a reboot. The official install script sets Node-RED up as a systemd service: start it with node-red-start and enable it at boot with sudo systemctl enable nodered.service. enable does not start the service now: add --now or run node-red-start. PM2 is another option described in the Node-RED documentation.systemctl is-enabled nodered.service prints enabled.
2. UserEach user has its own user directory, by default $HOME/.node-red. The service runs as the user in the User= line of /lib/systemd/system/nodered.service; the install script writes the user who ran it. If Node-RED was started once with sudo, the flows may be in /root/.node-red.The service user owns the .node-red folder that holds your flows.
3. Flows fileThe first lines of the log show "User directory" and "Flows file". If flowFile is not set in settings.js, the runtime uses flows_<hostname>.json, so a new hostname opens a new, empty file. Since Node-RED 2.0 the default settings.js sets flowFile: 'flows.json'; older installations keep their behaviour."Flows file" points to the file with your flows, with a fixed name.
4. Missing nodes"Waiting for missing types to be registered" means that the flows use nodes that are not installed in this user directory, often after a reinstall. The flows are still there. Install the nodes from Manage palette, or with npm install in the user directory, which reads package.json, and restart Node-RED.No missing types in the log.
5. NetworkAt boot the network can come up after Node-RED. The official service file has Wants=network.target, which says little about connectivity. Nodes that reconnect recover on their own. If a flow needs the network before it starts, add After=network-online.target and Wants=network-online.target to the service.The nodes connect, or the service waits for network-online.target.
6. Lognode-red-log follows the log of the service; systemctl status nodered.service shows its state and the latest log lines. If the service is not enabled, the log of the last boot can be empty: that points back to check 1."active (running)" and no errors.

Symptom, cause and what to do

  • Works with node-red by hand, not after a reboot: the service is not enabled. Run sudo systemctl enable nodered.service.
  • The editor is empty, with no errors: another user directory or another flows file. Read "User directory" and "Flows file" in the log.
  • The editor is empty after a hostname change: the flows file is flows_<hostname>.json. Set a fixed flowFile and rename the flows and credentials files.
  • "Waiting for missing types to be registered": nodes not installed in this user directory. Run npm install there or use Manage palette, then restart.
  • Network nodes red for the first seconds, then green: the network was not ready yet. That is normal if they reconnect; if not, add After= and Wants=network-online.target.
  • The editor is empty after a power cut: possible file system corruption. See the lesson on SD cards in the field.

Raspberry PLC

On Raspberry PLC, Node-RED is installed with the official script, as the Industrial Shields guide explains (see Next steps). The installation guide of the Raspberry PLC gives pi as the usual default user and, if the .node-red folder is not in $HOME, suggests checking /root: that is check 2.

The input and output nodes of the Raspberry PLC are in the package @industrial-shields/node-red-librpiplc, which needs the librpiplc library installed first. After a reinstall of Node-RED, these nodes are the ones that appear as missing types until you install them again in the user directory, from Manage palette or with npm.

Example configuration

Commands for Node-RED installed with the official script. Check the paths and the user on your installation before you change anything.

# 1. Service and start at boot
node-red-start                              # starts the service and shows its log
sudo systemctl enable nodered.service       # starts it at every boot (not now)
systemctl is-enabled nodered.service        # should print: enabled

# 2. Which user the service runs as
grep -E '^(User|Group|WorkingDirectory)=' /lib/systemd/system/nodered.service
sudo ls -d /home/*/.node-red /root/.node-red 2>/dev/null   # where the .node-red folders are

# 3. Which flows file it opens (first lines of the log; Ctrl+C to leave)
node-red-log
#   [info] User directory : /home/<user>/.node-red
#   [info] Flows file     : /home/<user>/.node-red/flows.json

# 4. Missing nodes: reinstall from package.json, as the service user
cd ~/.node-red && npm install
node-red-restart

# 5. Wait for the network (only if a flow needs it before it starts)
sudo nano /lib/systemd/system/nodered.service
#   [Unit]
#   After=network-online.target
#   Wants=network-online.target
sudo systemctl daemon-reload
node-red-stop && node-red-start

# 6. State and latest log lines
systemctl status nodered.service

Fixed flows file name in settings.js:

// settings.js, in the user directory: fixed flows file name
module.exports = {
    flowFile: 'flows.json',
    // ...
}

If you change flows_<hostname>.json to flows.json, rename the credentials file too (flows_<hostname>_cred.json to flows_cred.json) and test it on a copy. Do not start node-red by hand with sudo if the service runs as another user. The install script does not overwrite a modified nodered.service and says so in its log. sudo systemctl edit nodered.service, which creates a drop-in file with the same [Unit] lines, is an alternative to editing the file in /lib/systemd/system.

Next steps

Sources

nodered.org: Running on Raspberry Pi, Customising systemd on Pi, Starting Node-RED on boot (FAQ), Running Node-RED locally, Configuration (runtime), Adding nodes to the palette, and the Node-RED 2.0 release notes. systemd.io: Running services after the network is up. freedesktop.org: systemctl(1). Industrial Shields: Installing an operating system in the Raspberry PLC, How to install Node-RED onto a Raspberry Pi PLC or panel PC. flows.nodered.org: @industrial-shields/node-red-librpiplc.

Seis comprobaciones, en orden, para Node-RED que funciona si lo arrancas a mano pero no tras reiniciar el equipo Linux.

Commenting is not enabled on this course.