How to start/stop node-red? (and a bit more)

I was editing an existing flow and suddenly when I DEPLOYED I got a "server not responding" error.

This is what I get when testing the status of NR

pi@TimePi:~/.node-red $ sudo systemctl status nodered.service
● nodered.service - Node-RED graphical event wiring tool
   Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Fri 2025-03-14 18:47:44 AEDT; 2min 30s ago
     Docs: http://nodered.org/docs/hardware/raspberrypi.html
  Process: 13566 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=127)
 Main PID: 13566 (code=exited, status=127)

Mar 14 18:47:44 TimePi systemd[1]: Stopped Node-RED graphical event wiring tool.
pi@TimePi:~/.node-red $

How do I start NR is SAFE mode?

Searching it I get vague replies.
Sorry.

Also, adding to my confusion:

If I am in a terminal and try to run NR this is what happens:

pi@TimePi:~/.node-red $ node-red
-bash: node-red: command not found
pi@TimePi:~/.node-red $ 

Thoughts?

(more)

This is worrying.

This is after a reboot too.

And a bit more....

Until a few minutes ago when i was editing the flow things worked....

Yes it is "old" but it works.

If I type node -v I get back 14.21.3` which is a bit of a worry - in some ways - though I don't really know why.

It is running on the original dashboard.
It is a RasPi 3 B +
running buster.

I tried copying an older back up (from yesterday) and it still refuses to run.

if I try to run NR, I just get back a command not found error.

How broken is it?

More information:

Did you update npm? If so then you have ended up with a version of npm that won't run on your old version of nodejs.

I suggest that you run the node-red upgrade script to get back into a sane situation.

Make a backup of your flows file first, just in case.

[Edit] Don't run the upgrade script if you are running a version of the pi os older than buster.

First ensure it's stopped sudo systemctl stop nodered (you can add .service but it makes no difference)
Start in safe mode node-red --safe NB node-red has a hyphen.
The terminal output confirms it's in safe mode:

14 Mar 08:46:39 - [info] *****************************************************************
14 Mar 08:46:39 - [info] Flows stopped in safe mode. Deploy to start.
14 Mar 08:46:39 - [info] *****************************************************************

You can't use the terminal for anything else until you ctrl c, which will stop Node-red.
So then sudo systemctl restart nodered (no hyphen)

I didn't change NPM between the deploys.

(I'll read the other reply now)

Well, I'm not sure if it is or not stopped.

Though I'm guessing it is stopped.

pi@TimePi:~/.node-red $ sudo systemctl status nodered.service
● nodered.service - Node-RED graphical event wiring tool
   Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Fri 2025-03-14 19:15:48 AEDT; 10min ago
     Docs: http://nodered.org/docs/hardware/raspberrypi.html
  Process: 1102 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=127)
 Main PID: 1102 (code=exited, status=127)

Mar 14 19:15:48 TimePi systemd[1]: Stopped Node-RED graphical event wiring tool.
pi@TimePi:~/.node-red $

(and the machine has been rebooted.)

I can't start it as it says there is no such command and that NR is not fully installed.

pi@TimePi:~/.node-red $ node-red
-bash: node-red: command not found

OK, looking at your screen capture, node-red command is not found.

I'd make a backup of my flows then follow the advice to re-run the install script.

1 Like

I have a few listed as the one needed.

(Yes, my fault for not keeping them correctly identified.)

This one?

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Yes.
Might be worth checking your node.js version with node -v.
If it's less than v20, make sure the script updates it by appending --node20

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node20

When backing up, these are the only files to back up - yes?

It has (from memory) worked like that.

I stop NR, delete the existing, and then copy the backups to the NR directory.

node is 14.21.3

Yeah: OLD!
:frowning:

Did the command you posted.

Waiting now for things to happen.

You should backup the whole .node-red folder except for the node_modules folder.

1 Like

What kind of Pi is it? I find the install script takes about 5 min on any Pi with a quad core processor and 64 bit OS.
The script is interactive, should tell you how far it's got.

:frowning:

Running Node-RED update for user pi at /home/pi on raspbian


This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔   14.21.3-deb-1nodesource1
  Install Node 20.19.0-1nodesource1   ✘   Bad install:  Node.js missing  Npm missing - Exit
  Clean npm cache                     
  Install Node-RED core               
  Move global nodes to local          
  Npm rebuild existing nodes          
  Install extra Pi nodes              
  Add shortcut commands               
  Update systemd script               
                                      

Any errors will be logged to   /var/log/nodered-install.log

pi@TimePi:~/.node-red $ 

Sorry, help.

Oldish.

It is a RasPi 3 B +
running buster.

It is running on the original dashboard.

Raspberry Pi 3 Model B Plus Rev 1.3

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Raspberry Pi reference 2022-01-28
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 60f6a26ed5701eec6be5c864dd0db48fe6244fad, stage4
Linux TimePi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux
              total        used        free      shared  buff/cache   available
Mem:          923Mi       191Mi       145Mi        18Mi       586Mi       651Mi
Swap:          99Mi       3.0Mi        96Mi

This is the error log:

pi@TimePi:~/.node-red $ cat /var/log/nodered-install.log
Already have nodejs 14.21.3-deb-1nodesource1
OLD nodejs 14 :
NEW nodejs 20 :
Installing nodejs 20 over 14 .

***************************************

Started : Fri 14 Mar 20:02:39 AEDT 2025
Running for user pi at /home/pi
Found global nodes:   :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodered' is not installed, so not removed
The following package was automatically installed and is no longer required:
  libdav1d3
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Installing nodejs 20

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'npm' is not installed, so not removed
The following package was automatically installed and is no longer required:
  libdav1d3
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  nodejs
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 115 MB disk space will be freed.
(Reading database ... 108359 files and directories currently installed.)
Removing nodejs (14.21.3-deb-1nodesource1) ...
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/yallist' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/write-file-atomic' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/wrap-ansi/node_modules' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/which/bin' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/validate-npm-package-name' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/validate-npm-package-license' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/util-deprecate' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/unique-slug' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/unique-filename' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/tiny-relative-date' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/text-table' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/tar/node_modules/minipass' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/tar/lib' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/ssri' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/spdx-expression-parse' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/spdx-exceptions' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/spdx-correct' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/socks' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/socks-proxy-agent' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/smart-buffer' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/signal-exit' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/semver/bin' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/safer-buffer' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/retry' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/read' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/read-cmd-shim' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/qrcode-terminal' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/promzard' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/promise-retry' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/promise-inflight' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/pacote/lib/util' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-user-validate' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-registry-fetch' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-profile' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-pick-manifest' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-packlist' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-package-arg' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-normalize-package-bin' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-install-checks' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-bundled' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/npm-audit-report/lib' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/normalize-package-data' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/nopt/lib' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/node-gyp/lib' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/data' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/mute-stream' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/ms' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/mkdirp' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/minizlib/node_modules/minipass' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/minimatch' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/make-fetch-happen' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/lru-cache' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/libnpmteam' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/libnpmsearch' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/libnpmpublish' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/libnpmorg' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/libnpmhook' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/libnpmaccess' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/jsonparse' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/json-parse-even-better-errors' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/isexe' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/jsbn' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/is-cidr' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/init-package-json' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/ini' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/ignore-walk' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/iconv-lite/encodings' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/https-proxy-agent' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/http-proxy-agent' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/http-cache-semantics' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/hosted-git-info' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/graceful-fs' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/glob' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/fs-minipass' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/err-code' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/encoding' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/emoji-regex' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/debug/src' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/debug/node_modules/ms' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cross-spawn/node_modules' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cross-spawn/lib/util' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/color-name' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/color-convert' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cmd-shim/lib' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cli-columns' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cidr-regex' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/ci-info' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/chownr' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/chalk' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cacache/lib/util' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/brace-expansion' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/bin-links' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/balanced-match' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/archy' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/aproba' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/agent-base' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/abbrev' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/man/man7' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/man/man5' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/man/man1' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/lib/utils' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/docs/output/using-npm' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/docs/output/configuring-npm' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/docs/output/commands' not empty so not removed
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/bin' not empty so not removed
Processing triggers for man-db (2.8.5-2+deb10u1) ...
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  libdav1d3
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 610 kB disk space will be freed.
(Reading database ... 103440 files and directories currently installed.)
Removing libdav1d3:armhf (0.5.1-1~bpo10~1) ...
Processing triggers for libc-bin (2.28-10+rpt2+rpi1+deb10u2) ...
Grab the LTS bundle

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
ca-certificates is already the newest version (20200601~deb10u2).
curl is already the newest version (7.64.0-4+deb10u9).
gnupg is already the newest version (2.2.12-1+rpi1+deb10u2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
gpg: WARNING: unsafe ownership on homedir '/home/pi/.gnupg'
Get:1 https://deb.nodesource.com/node_20.x nodistro InRelease [12.1 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Get:3 https://deb.nodesource.com/node_20.x nodistro/main armhf Packages [10.9 kB]
Get:4 http://archive.raspberrypi.org/debian buster InRelease [54.2 kB]
Get:5 http://archive.raspberrypi.org/debian buster/main armhf Packages [400 kB]
Fetched 493 kB in 3s (143 kB/s)
Reading package lists...

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.4 MB of archives.
After this operation, 186 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_20.x nodistro/main armhf nodejs armhf 20.19.0-1nodesource1 [28.4 MB]
Fetched 28.4 MB in 5s (5,274 kB/s)
Selecting previously unselected package nodejs.
(Reading database ... 103436 files and directories currently installed.)
Preparing to unpack .../nodejs_20.19.0-1nodesource1_armhf.deb ...
Unpacking nodejs (20.19.0-1nodesource1) ...
Setting up nodejs (20.19.0-1nodesource1) ...
Processing triggers for man-db (2.8.5-2+deb10u1) ...

Versions: node:missing npm:missing

This sort of worries me:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

It is in a CLI/Terminal on the machine.

Well Debian Buster is kind of out of date.
How much stuff besides Node-red do you have on the Pi?

Perhaps it's worth a fresh install, maybe on a new Sandisk Ultra micro SD.
Install Node-red then copy (at least) the flows and flows_cred files from your backup.