Troubleshooting
Rebuild Node-RED serialport modules on a 32-bit ARM edge PC
Short answer
The crash comes from the serialport native binding: 32-bit ARM gets no prebuilt binary, so a serial flow deploy kills Node-RED and the container. Open the container as root, run npm rebuild --build-from-source from /data/, restart, and repeat the rebuild after every serialport palette install. Keep one owner on the serial port, and set RS-485 or RS-232 with the controller's serial-mode tool.

On this page
Node-RED in Docker on a 32-bit ARM controller does not fail quietly on serial: the moment a flow with a serial node deploys, the process dies and the container will not come back up. The cause is the serialport node's native binding, compiled C++ that must match the controller's CPU, with no prebuilt binary published for 32-bit Linux ARM, so the copy on the controller is missing or broken and loading it kills Node-RED. The fix is a rebuild from source inside the container: open the container as root, change to its data directory, run npm rebuild --build-from-source, restart, and repeat that rebuild after every serialport palette install. Then set the port's electrical mode with the controller's serial-mode tool and keep one owner on the port at a time.
Confirm the crash is the native binding, not the port #
The reported pattern is consistent:
- Node-RED exits the instant a flow containing a serial node is deployed, or at startup once a device is connected to the port.
- The container will not stay up afterwards; recreating it, rebooting the controller and factory resets changed nothing in the reported cases.
- A restart policy only replays the crash: the container exits again as soon as the flow loads the serial node.
- Flows without serial nodes keep running, which puts the fault in the module, not in Docker or the wiring.
Capture the last crash log before changing anything. A trace that names the serialport binding confirms the diagnosis; a trace that names something else sends you to a different fault.
Confirm the platform before rebuilding. Inside the container, node -p process.arch prints arm for 32-bit ARM and arm64 for 64-bit; on the controller shell, uname -m printing armv7l says the same about the machine. If the container reports arm64, prebuilt binaries exist for that platform, so a deploy crash has another cause: read the log instead of rebuilding.
A rebuild that stops the crash proves only that the binding loads. It does not prove the device is mapped into the container with working permissions; the Node-RED Docker documentation notes that serial access may require adding the container to the dialout group with --group-add dialout. Device mapping and permissions are covered step by step in Expose a serial port to Node-RED in a Docker container. Wiring and protocol come after the crash is gone.
Rebuild the serialport module from source in the container #
- Connect to the controller over SSH and elevate to root with
su -. A container-management web UI works too: open the container console as root there. - Open a shell in the running container as root, using your container's name:
docker exec -ti --user root <containername> /bin/bash - Change to the Node-RED data directory:
cd /data/ - Rebuild the installed modules from source:
npm rebuild --build-from-source - Exit the container and restart it:
docker restart <containername>, or restart from the container manager. - Deploy the serial flow. Node-RED should now stay up.
Worked example for a deployment whose container is named nodered, an example name to substitute with your own:
su -
docker exec -ti --user root nodered /bin/bash
cd /data/
npm rebuild --build-from-source
exit
exit
docker restart nodered
What the rebuild does: npm rebuild recompiles the packages in the current directory's node_modules, and --build-from-source forces compilation on the controller's own CPU instead of fetching a prebuilt binary, the binary that does not exist for this platform. That is why it runs as root, inside the container, from the directory that holds the module.
Compilation needs a toolchain. A source build runs node-gyp, which calls a C/C++ compiler, make and Python; a stripped-down industrial image can be missing any of them, and the rebuild then stops with compiler or gyp errors instead of a clean finish. That failure family on embedded controllers, together with registry-resolution stalls, is worked through in Resolving npm EAI_AGAIN and node-gyp errors on embedded controllers. Sort the toolchain out first, then rerun the rebuild.
Rebuild again after every serialport palette change #
The rebuild fixes the modules present when it runs. Installing or upgrading a serialport node brings a fresh copy of the binding, and the crash returns, reported repeatedly, including an engineer who confirmed the rebuild had stopped the crash and saw it come back immediately after installing the serialport palette. Upgrades trigger it as well: a Raspberry Pi 4 report had Node-RED die at startup with a device connected right after the node-red-node-serialport palette moved from version 0.8.8 to 1.0.1. The rule is mechanical: after any palette install or upgrade that touches serialport, rerun the same two commands from the data directory, restart, and redeploy.
If the crash loop is tight enough that the editor never becomes reachable, recover through safe mode and roll the install back as described in Node-RED crashes after a node install: safe mode and rollback, then rebuild and redeploy.
A palette install that cannot even begin is usually the network, not the module. A controller that reaches npm through a plant proxy fails its registry requests with a separate error; that path is covered in Fix npm E502 when installing Node-RED nodes behind a proxy.
One reported fallback has limits. An engineer stopped a stubborn crash by removing the serialport node and installing version 0.15.0, an old release. Treat that as a compatibility test which confirms the binding is the fault: 0.15.0 is not established as a general remedy, and the rebuild on the current palette is the fix to keep.
Set the electrical mode: RS-485 or RS-232 #
The onboard port's electrical standard is set from the controller shell, not from Node-RED. On this controller class the tool is set_serial_mode, kept in /etc/config-tools/:
cd /etc/config-tools/
./set_serial_mode rs485 # RS-485, the default mode on these controllers
./set_serial_mode rs232 # RS-232
Three things must agree after the change: the mode you set, the serial node's setting in the flow, and the device on the wire. An RS-232 device behind an RS-485 port exchanges nothing, no matter how healthy Node-RED is. Order matters when both faults are present: a mode change cannot stop a module crash, and one engineer who switched to RS-232 still lost Node-RED on deploy, so rebuild first and set the mode second.
Change the mode and move wiring only with the loop out of service; on a live line that is a control-signal interruption, not a hot swap.
One owner for the serial port #
The PLC runtime and Node-RED in Docker can run side by side on these controllers; guidance telling you to unload the runtime is solving a different problem. The rule is one owner per resource: only one application may open the serial interface at a time, and the same holds for the controller's internal I/O bus. Keeping the runtime loaded is fine as long as its configuration does not claim the port Node-RED uses, so assign the port to Node-RED explicitly, keep the runtime's I/O configuration away from that interface, and test. If both applications genuinely need the same port, move one consumer to a second interface rather than interleaving access.
Decision after each check #
| Check | Pass condition | Next decision |
|---|---|---|
| Platform | node -p process.arch prints arm in the container |
arm64 or x64 means another fault: read the log before rebuilding |
| Container stability | Node-RED stays up after the serial flow deploys | Crash returns: check the log and rerun the rebuild after the last palette change |
| Rebuild result | npm finishes cleanly and lists the serialport package | Compiler or gyp errors mean toolchain first, rebuild second |
| Electrical mode | The mode set with set_serial_mode matches the flow setting and the device | Mismatch: set the mode the device speaks, then retest |
| Resource ownership | Exactly one application opens the port and the internal I/O bus | Remove the second owner before any protocol troubleshooting |
| Data flow | The serial In node shows the expected bytes | Stable but silent is wiring and protocol configuration, not the module |
Work the checks in that order, log, platform, rebuild, mode, ownership, data, and only then argue with wiring and protocol settings.
Questions asked
Why does Node-RED stay up until the serial flow deploys?
The serialport binding loads only when a serial node in the flow initializes. Pure JavaScript nodes run anywhere, but serialport also carries a compiled C++ binding that must match the CPU architecture and the Node.js version inside the container. No prebuilt binary is published for 32-bit ARM, so the load fails hard and takes the whole process down, which is why the crash appears exactly at deploy.
Does the rebuilt binding survive recreating the container?
A rebuild covers the modules in the directory you run it from. Palettes installed through the palette manager live in the data directory, which stays on a host volume, so their rebuilt binding survives container recreation. A module baked into the image has to be rebuilt wherever the image keeps it, and an image upgrade swaps in the image's own copy, so if the crash returns after an upgrade, rebuild again.
Does the same fault hit a native Node-RED install outside Docker?
It can. The missing prebuilt binary is a platform and Node.js version problem, not a container problem, and reported failures cover 32-bit ARM boards generally, including single-board computers. On a native install, run the rebuild in the directory holding the Node-RED installation and repeat it after palette changes the same way; Docker only adds the step of running the rebuild as root inside the container.
What if npm rebuild itself fails?
A source build runs node-gyp, which needs a C/C++ compiler, make, Python and the matching Node.js headers inside the container. Missing tools stop the build with compiler or gyp errors; sort the toolchain out, then rerun the rebuild. If the failure is about reaching the npm registry, with DNS or proxy errors, that is a network fault, and it has to clear before any source build can fetch what it needs.

