Troubleshooting
Node-RED crashes after a node install: safe mode and rollback
Short answer
The fatal log line is the one reading Uncaught Exception with a stack trace; palette warnings above it are survived. Stop the nodered systemd unit, start node-red with --safe so the editor opens with flows stopped, then roll the package the stack names back to its previous release with npm install --save-exact and confirm the pin with npm ls before you let the flows run.

On this page
- Why does Node-RED keep crashing after installing new nodes?
- Which log line is fatal, and which warnings can I ignore?
- How do I stop the restart loop and keep the stack trace?
- How do I start the editor without running the flows?
- Which node does the stack trace name as the killer?
- What should I do about the modbus node that cannot load?
- How do I roll the S7 node back to the last working version?
- How do I verify the fix and keep the pin from slipping?
- Questions asked
Deleting nodes at random is the wrong first move when Node-RED dies right after an install: the log already names the guilty package. Only one line in it is fatal, the one reading [red] Uncaught Exception: followed by a stack trace; every palette warning above it is noise the runtime survived. In the reported case behind this article, Node-RED v0.20.8 on Node.js v10.15.3 exited about one second after Started flows because the nodes7 S7 library threw ReferenceError: outputlog is not defined. The fix is three moves: stop the nodered systemd unit, restart with node-red --safe so the editor runs while the flows stay stopped, then pin the package the stack names back to its last working release with npm install --save-exact and prove the pin with npm ls.
Why does Node-RED keep crashing after installing new nodes? #
Because one exception escaped the flow layer and reached the Node.js event loop: the log shows Started flows, then [red] Uncaught Exception: about one second later, then Main process exited, code=exited, status=1/FAILURE, and systemd schedules a restart that repeats forever.
Node-RED terminates on any exception that reaches the event loop. A catch node intercepts errors a node reports while it handles a message; it cannot intercept a throw raised inside library code on a socket callback. When such a throw fires, the process dies and every flow on the runtime dies with it, including the MQTT broker, the Modbus traffic and everything else that was healthy.
The timeline from the reported case reads like this:
11:34:10—Starting flows; the S7 client and the Modbus connections open11:34:10—Started flows11:34:11—[red] Uncaught Exception:ReferenceError: outputlog is not defined11:34:11— systemd marks the unit failed with resultexit-code11:34:13— a freshWelcome to Node-REDbanner and the palette loads again
The arithmetic decides the diagnosis: 11:34:11 minus 11:34:10 is one second between flows start and death, and the restart lands about two seconds after the exception. That one second is not random — it is the first PLC reply reaching the library, because the fault sits in the receive path; the stack-trace section below names it.
Which log line is fatal, and which warnings can I ignore? #
The fatal line is the one that reads [red] Uncaught Exception: followed by an error name and a stack trace; everything Node-RED labels [warn] is non-fatal, and the Cannot find module entry for node-red-contrib-modbustcp-no-pooling is a warning, not the crash.
Decode each line in the startup log by what it does to the runtime:
| Log line | What it means | Action |
|---|---|---|
[warn] [node-red-contrib-modbustcp-no-pooling/modbus tcp] Error: Cannot find module '/usr/lib/node_modules/node-red/red/red' (line:46) |
The package needs a Node-RED internal file by an absolute path this layout does not have; that node type fails to register and the runtime carries on | Remove or replace the package (section below) |
[error] [eth-ip in:Test] Missing configuration |
An EtherNet/IP input node was deployed with no connection configured; it sends no traffic | Configure the node or delete the unused test node |
[error] [modbustcp-read] ModbusException, _fc: 2, _code: 2 |
The controller answered function code 2, read discrete inputs, with exception code 2, illegal data address: the TCP path works, the requested address range does not | Compare the node's start address and quantity with the device's Modbus map, watching 0-based versus 1-based offsets |
[error] [mqtt-broker] Connection failed to broker (loopback address, port 1883) |
The first connect attempt races the moment the embedded broker binds its port; the client retries | Confirm it reconnects; if not, check whether another process holds port 1883 |
[red] Uncaught Exception: plus a stack trace |
A throw escaped the runtime; the process exits and systemd restarts it | Stop the unit, safe mode, roll back (sections below) |
The Modbus exception row is worth reading closely: an exception response proves the path to the controller is alive through TCP port 502 and the Modbus application layer, because a dead path answers with a timeout, not an exception. None of the first four rows stops the runtime; only the last row does.
How do I stop the restart loop and keep the stack trace? #
Stop the unit before you edit anything: sudo systemctl stop nodered ends the loop, and journalctl -u nodered -f follows the log live so the next crash prints its complete stack trace instead of scrolling away between restarts.
sudo systemctl stop nodered
journalctl -u nodered -f
Confirm the loop is really stopped:
systemctl status noderedreports the unit inactive.- No new
Welcome to Node-REDbanner appears in the journal.
What systemd does after each exit is its restart policy; Node-RED crash and memory growth: systemd restart recovery covers that policy and the memory-growth case that ends in the same kind of loop.
How do I start the editor without running the flows? #
Start Node-RED in safe mode: the documented --safe option starts Node-RED without starting the flows, so the editor opens while no S7 or Modbus socket is created and the library fault cannot fire.
Run it in the foreground on the gateway:
node-red --safe
Safe mode loads the palette, the runtime and the editor and leaves the flows stopped. The flows file, the credentials and the user directory ~/.node-red are read as always, so nothing you fix in the editor is lost. The editor answers on port 1880; the reported case bound the loopback interface, so check the bind address your settings file configures before browsing from your desk.
You know safe mode is up when:
- the console prints the editor address and never prints
Starting flows - the editor loads in a browser and the process is still alive a minute later
- no S7 or Modbus connection attempt appears in the log
Which node does the stack trace name as the killer? #
The stack trace names it: ReferenceError: outputlog is not defined at NodeS7.readResponse in nodes7/nodeS7.js:1427:4, called from NodeS7.onResponse at line 1229 — nodes7 is the S7 library that the node-red-contrib-s7 palette node loads, so that package is the one to roll back.
Read the two frames together: readResponse ran from onResponse, which is the receive path for a PLC reply. The identifier outputlog is never declared in that scope, so the first reply that reaches that line throws — which is the mechanism behind the one-second timing. Three details in the reported case corroborate the package: removing the modbus package did not stop the crash, the S7 package had been updated about two weeks before the failure, and flows that excluded the S7 nodes ran without crashing.
If this gateway is a compact IIoT box, installing node-red-contrib-s7 brings npm quirks of its own; the knowledge-base walkthrough of installing node-red-contrib-s7 on a Siemens IOT2040 covers the npm resolution steps that come before any rollback.
Decision: treat the package the stack names as guilty until a pinned version proves otherwise.
What should I do about the modbus node that cannot load? #
Remove it or replace it, but do not expect its removal to stop the crash: the Cannot find module warning means the package fails to register one node type, which degrades the palette without killing the runtime.
The warning names its own cause: the package requires the Node-RED internal file node-red/red/red by an absolute path that does not exist in this install layout, so its node type never registers. Windows installs of the same package fail the same way, which marks it as a package defect rather than a Raspberry Pi or Linux problem.
Your two options:
- Remove the package with
npm remove node-red-contrib-modbustcp-no-pooling, run in~/.node-red. Itsmodbustcp-readandmodbustcp-servernodes then appear as unknown nodes; re-point them to a maintained Modbus TCP node and redeploy. - Patch the require line inside the package as a stopgap. The edit lives in unmaintained third-party source and disappears on every reinstall, so plan the replacement either way.
The check proves the two faults are independent: restart in safe mode and the Cannot find module warning disappears from the palette load, while the S7 crash — if the rollback has not happened yet — remains.
How do I roll the S7 node back to the last working version? #
Pin the exact previous release instead of a range: npm install --save-exact with the release number selects one version, and npm ls confirms afterwards what is actually installed for node-red-contrib-s7 and its nodes7 library.
- Back up
~/.node-red/package.jsonand the project folder under the user directory; a project keeps its ownpackage.jsonlisting node dependencies, so check that file too. - Record what is installed now:
npm ls node-red-contrib-s7 nodes7, run in~/.node-red. - List the releases and their dates:
npm view node-red-contrib-s7 versions, thennpm view node-red-contrib-s7 time. Pick the newest release dated before the update that broke the gateway — about two weeks before the failure in the reported case. - Install that release exactly, putting the number from step 3 in place of the angle-bracket placeholder:
npm install --save-exact node-red-contrib-s7@<last-good-version>
- Re-check the library:
npm ls nodes7. If a caret range resolved the newer release again, pin the library itself with the version from the working release:
npm install --save-exact nodes7@<version-from-the-working-release>
- Confirm the result:
npm ls node-red-contrib-s7 nodes7must list both packages at the pinned versions with noinvalidorextraneousmarks.
The undeclared identifier sits in the library's source code, so no change to the flow configuration can remove it. Rolling back, or moving to a corrected upstream release when one appears, is the cure; everything else is symptom management.
How do I verify the fix and keep the pin from slipping? #
Prove it on the running gateway, not in the editor: npm ls must show both pinned versions without invalid or extraneous marks, and the journal must stay free of Uncaught Exception through several full PLC poll cycles.
Restart the service normally with sudo systemctl start nodered, or enable the flows from the editor, and stay on journalctl -u nodered -f long enough to cover several S7 poll cycles; the fault fired on the first reply before, so a few cycles are a real test. One safety note: if these flows drive physical outputs, bring the line to a safe state before the flows start again. Also confirm the disk state: the file under node_modules/nodes7/ carries the older release and package.json names the exact version without a caret prefix.
Keep the pin: run npm update on a plant gateway only deliberately, never as routine maintenance, and re-run npm ls for the pinned packages after any change to the node set. For gateways that must hold a fixed node set even when installs happen offline, Stable Node-RED gateway flows with vendor-pinned nodes shows the pinning discipline end to end.
The decision, case by case: a [warn] line costs one node type and can wait for a planned window; an [error] line about a connection needs a mapping or configuration fix, not a reinstall; and [red] Uncaught Exception: kills the process — stop the unit, safe mode, roll back the package the stack names, verify with npm ls, then watch the journal before you call the gateway healthy.
Questions asked
Do I need to reinstall Node-RED or reset it to fix a crash loop?
No. A crash loop leaves no damage to repair: the flows, credentials and settings on disk are intact, and reinstalling the runtime would not remove the defective node package anyway. Fix the package the stack trace names. If you want a genuinely clean palette, back up package.json and the projects folder first, because deleting the user directory is what deletes your flows.
Can a later npm update undo the version pin?
Yes. npm update does not keep specified dependency ranges in package.json, so a routine update on the gateway can pull the newer library release again. After any update, run npm ls for the packages you pinned and check that package.json still names the exact version. Treat npm update on a plant gateway as a change that needs the same verification as the rollback did.
How do I report the broken node so it gets fixed?
Open an issue in the node package's own repository. Include the stack trace with the file and line number, the Node-RED and Node.js versions from the startup banner, and the note that flows without that node type run fine. The defect sits in the library source, so only the maintainer can declare or guard the missing identifier.
Is safe mode available on packaged gateways, not just the command line?
On a plain Linux install the flag is the direct way. Packaged distributions add their own switches: the Home Assistant add-on takes a safe_mode option that sets the same flag, and Venus OS discussions propose a menu entry for it. Whatever the wrapper, the effect is identical: the editor runs while the flows stay stopped, so the same repair steps apply.