Troubleshooting
Why Node-RED crashes on deploy for a missing OPC UA certificate
Short answer
The crash is a local file lookup, not a network or server fault: deploying starts the OPC UA connector, the connector builds an OPC UA client, and that client throws cannot locate certificate file for its self-signed certificate before touching the network. Recover the editor in safe mode, give the Node-RED service account a writable certificate directory, redeploy, and only replace the package or move to a container if provisioning stays unmaintainable.
On this page
- Why does Node-RED stop when I deploy an OPC UA flow?
- How do I read the stack trace in the controller log?
- How do I get the editor back without reinstalling?
- Why is the certificate on my Windows PC but missing on the controller?
- What permissions does the certificate directory need?
- When should I replace the package instead of repairing it?
- Does running Node-RED in a container avoid this on the controller?
- How do I verify the repair before trusting the controller?
- Questions asked
Deploying an OPC UA flow should not take Node-RED down with it. When it does, the cause sits on the controller, not in the network: the connector builds its OPC UA client at deploy time, the client insists on its self-signed certificate, the file is not there, and the exception stops the whole runtime. Work through the failure in the order you meet it — read the stack trace, recover the editor in safe mode, find out why the certificate exists on your Windows PC but not on the controller, repair the certificate directory with the right ownership, then decide between repairing the package, replacing it or moving Node-RED into a container.
Why does Node-RED stop when I deploy an OPC UA flow? #
Deploying starts the OPC UA connector, the connector schedules a connection attempt, and that attempt begins by constructing an OPC UA client; when client construction throws an unhandled exception, the whole Node-RED process dies, so the editor stops booting before any network connection is attempted.
Deployment restarts the configured nodes of a flow. The OPC UA connector schedules its first connection attempt on a timer, and that timer callback builds the client through connectOPCUAEndpoint. Construction is where the runtime dies: the base class OPCUAClientBase checks that its certificate and private key exist before it does anything else, and the missing file raises an exception that escapes the connector's error handling and terminates the Node-RED process — not just the one connector.
That timing explains each symptom. Other flows keep working because they never enter this path, so the crash appears only when the OPC UA flow deploys. A service restart loads the saved flow and walks the same construction path again, which is why the editor never comes back on its own.
How do I read the stack trace in the controller log? #
The error to look for is cannot locate certificate file, and the path printed after it names the exact file your installed client expects; read that path from your own log, because the stack below the error ends in client construction, not in a server or network response.
The reported stack reads, from the failure upward:
OPCUAClientBaseinclient_base.js— the constructor that demands the certificate file. This is the failure point.new OPCUAClientinopcua_client.js— ordinary client creation on top of that base.connectOPCUAEndpointin the connector'sopcua-iiot-connector.js— the connector's timer callback that started the build.listOnTimeoutandprocessTimersin the Node.js timer internals — proof the build ran on a timer, outside the deploy call itself.
Read the wrapped path as one string: controller logs fold long paths across lines, and the pieces reassemble into a single file name. In this incident it ends in node-opcua-client/certificates/client_selfsigned_cert_1024.pem, inside the package's own nested copy of node-opcua-client — so provisioning belongs to that copy, not to another node-opcua elsewhere on the controller. No endpoint URL, port or firewall setting matters yet: a client that never constructs never reaches the network.
How do I get the editor back without reinstalling? #
Start Node-RED in safe mode with its documented safe-mode flag (node-red --safe): flows load for editing but nodes do not run, so the failing connector stays inactive while you repair the certificate directory, and you break the crash-reinstall-crash cycle. If a service manages the runtime, add the flag to that service's start command for the recovery boot.
- Back up the Node-RED user directory first: the flow file, its credentials file and the package manifest. A repair must never cost you flows.
- Stop the service while it is crash-looping so the log stays readable.
- Start in safe mode and confirm the rest of your flows are intact.
- Leave the OPC UA connector as it is; you will deploy it again as the final test.
- After the certificate repair below, restart normally and deploy once.
Treat uninstall-and-reinstall as a way back into the editor, never as the fix: it replaces package files but leaves the certificate folder exactly as it was, so the next deploy reproduces the crash.
Why is the certificate on my Windows PC but missing on the controller? #
The self-signed certificate pair is generated on first use, and that generation happens when the process can create its certificates folder; a Windows PC install runs under your own account with write access, while a controller install runs as a service account that cannot write into the module tree.
Three conditions produce the missing file on a controller:
- Installation does not always create the self-signed certificates a client needs; the pair is expected to appear on first use instead of at install time.
- The certificate manager must be able to create its folder; when it cannot, this class of error appears.
- Key generation can fail midway and leave a certificates directory holding neither the private key nor the certificate; one generation-failure report ends with the message
private file must existwhile the manager looks in the certificates directory.
On the PC, the palette install lands in a folder your user owns, so the pair is generated silently on the first connect. On the controller, Node-RED runs as a service account while the package sits in a global, root-owned module path: the client looks for its certificate folder, cannot create it, and throws at construction.
What permissions does the certificate directory need? #
Give the account that runs Node-RED ownership of the certificates folder named in the log, with owner read-write-execute — mode 0755 is enough: as root, create the folder, hand it to the service account, restart, and let the client generate the pair on first connect.
Worked example, with illustrative account names: the folder /opt/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/node-opcua-client/certificates is owned by root with mode 0755, and Node-RED runs as a service account, node-red for this example. Mode 0755 decodes as owner read+write+execute = 4+2+1 = 7, group read+execute = 4+1 = 5, others read+execute = 4+1 = 5. The node-red account is "other" relative to that folder: it can read and traverse but holds no write bit, so it cannot create the folder or the files inside it, and client construction throws. The repair is ownership, not looser permissions: as root, create the certificates folder and hand it to node-red. Mode 0755 now serves, because the owner's write bit — the 2 in 4+2+1 = 7 — belongs to the service account itself; on the next start the client writes its self-signed pair into a folder it owns.
After the restart, expect a certificate and a private key in that folder, and do not anchor on the file name from this incident: the nested client copy decides the name. Newer node-opcua generations produce 2048-bit keys — one report shows server_key_2048.pem — so your repaired folder may hold 2048-bit names instead of client_selfsigned_cert_1024.pem. Verify against the path your own log printed, listed as the service account, not as root.
When should I replace the package instead of repairing it? #
Replace the toolbox package only when its certificate handling cannot be made maintainable on your controller: the alternative client package installs from source on a controller, with npm compiling what needs compiling against your own Node.js rather than trusting a prebuilt tree.
The toolbox is a community contribution built on node-opcua, not an official OPC Foundation product, so treat it as one dependency choice among two. If you switch, update the native build tool first and install the client package from source; global installs on a controller run scripts as root, which is why the from-source install carries the unsafe-perm flag:
npm install -g node-gyp@latest
npm install -g node-red-contrib-opcua --unsafe-perm --build-from-source
A clean compile is the evidence that the dependency tree resolved on this architecture. It is also a commitment: a package you build yourself is a package you rebuild on every update. Whichever package you keep, audit its dependency tree at install time — the npm vulnerability findings for node-red-contrib-iiot-opcua show what that audit turns up for this exact package.
Decision: repair the folder first — minutes of work, no rebuild. Replace the package when a correctly owned, writable certificate folder keeps failing across restarts, or when you need client features the toolbox does not have.
Does running Node-RED in a container avoid this on the controller? #
A container helps because its filesystem is built for the container's own user: dependencies install into writable paths and the certificate folder is created on first use, so the missing-file crash is far less likely — but you must mount a volume so certificates and flows survive an image rebuild.
Run Node-RED from a maintained container image and the certificate folder is created inside the container, under a user that owns it, on the first connect. The trade is persistence: flows, credentials and the certificate store live in the container's writable layer and vanish on rebuild, so mount a volume for the user directory and keep the certificate store inside it. Certificates in a container also age: once the store survives rebuilds, the opposite failure becomes possible — an expired x509 certificate in a Node-RED container on an edge PC, which has its own recovery procedure.
Decision: choose the container when you want dependency isolation on this controller anyway. Do not choose it as a workaround for a folder permission you have not yet checked — the bare-metal repair above is smaller than a runtime migration.
How do I verify the repair before trusting the controller? #
Verify four things in order — the runtime survives a deploy, the certificate pair exists under the path your log named, the service account can read it, and a known tag updates through the flow; only a confirmed value on the server side counts as fixed.
Work down this list and stop at the first failure:
- Deploy the OPC UA flow twice with no restart in between; the runtime must stay up both times.
- List the certificates folder as the service account and find both the certificate and the private key.
- Restart the service once more and let the saved flow boot untouched — that proves the crash loop is gone, not just this session.
- Watch a known tag update through the flow; data arriving at the endpoint is the only proof the channel carries values.
If the runtime stays up but the endpoint still refuses the client while a desktop OPC UA client connects to the same server, move on to the Node-RED OPC UA troubleshooting for when UaExpert connects — that is a different fault with a different fix.
One line while you are in there: do not make the crash disappear by dropping the client to a no-security policy on a plant network — fix the provisioning and keep the signed, encrypted channel. Record the Node-RED, Node.js and package versions before and after the repair; a short change record is what makes the next incident short.
Decision: all four checks pass — keep the repaired install. A check still fails after a correctly owned, writable certificate folder — replace the package first, then move to the container, in that order.
Questions asked
What does the 1024 in client_selfsigned_cert_1024.pem mean?
It is the RSA key size of the certificate that copy of node-opcua expects: 1024 bits. Modern node-opcua versions generate 2048-bit keys instead, and current NIST guidance sets 2048 bits as the minimum RSA key size for new digital signatures, so a repaired install that still provisions a 1024-bit certificate deserves a planned package update. Match the file name your own log prints and do not rename files by hand.
Why does reinstalling Node-RED fix the crash until the next deploy?
Reinstalling replaces the package files but not the certificate condition. Right after a reinstall the editor boots because nothing has started the OPC UA connector yet; the moment you deploy the flow, the connector rebuilds its client, repeats the same failed lookup and kills the runtime again. Reinstalling is a way back into the editor, not a repair: fix the certificate folder's existence and ownership, then test with a deploy.
Can I copy a working certificate from my Windows PC to the controller?
It would satisfy the file check, but it is poor practice. A client certificate identifies one application instance, and its private key should live only on that machine; duplicating the pair means two systems share one identity. Generate the certificate on the controller itself, as the controller's own service account, so the identity matches the machine and the key never leaves it.
Which account should run Node-RED on the controller?
A dedicated, non-root service account that owns the Node-RED user directory and the certificate folder underneath the installed OPC UA package. That single decision prevents the whole failure class: the certificate manager can create its folder, generate the key pair on first use, and replace certificates later without a root shell. Avoid running the runtime as root just to make permission errors disappear.