Troubleshooting
Why a Node-RED deploy fails on OPC UA certificate file permissions
Short answer
When a Node-RED OPC UA flow fails to deploy with a permission-denied error, the account running the Node-RED process cannot traverse a parent directory or read a certificate or key file. Diagnose with the error path, the runtime identity and ls -l, then apply a targeted chown or read grant. A recursive 777 change hides the cause and exposes private keys.
On this page
A deploy that fails with permission denied on a certificate is not a Node-RED bug: the account running the Node-RED process cannot traverse one of the certificate directories or read the certificate or key file the OPC UA node opens at deploy time. Fix it by identifying the exact path in the error, checking which account actually runs Node-RED, and granting that account only the access it lacks. Do not use a recursive 777 change on a certificate tree, because the same tree holds private keys.
This differs from a missing certificate: when the certificate is simply absent, the deploy crashes for a different reason, covered in article:why-node-red-crashes-on-deploy-for-a-missing-opc-ua-certificate. Here the file exists and the failure is an access control decision, which you can read directly from the error and the file system.
Read the error as a filesystem denial #
The permission-denied message names the path and the operation that failed: an open, a read or a directory scan. Keep the exact spelling and capitalization, because that is the object to inspect. If the editor shows only a generic deploy failure, watch the Node-RED runtime log while you deploy; the node prints the failing path there.
Remember what a successful editor connection proves and does not prove. Your browser talks to the Node-RED editor over HTTP; the certificate access happens inside the Node-RED process when the OPC UA node loads its configuration. A working editor with a failing deploy means the network path is fine and the filesystem path is not.
Check which account runs Node-RED #
Linux evaluates every file access against the identity of the running process, not against the account open in your terminal and not against the account that installed the package. A Node-RED service launched by systemd can run under a dedicated service account, such as node-red, while you troubleshoot as an administrator or as a default login like pi.
Confirm the identity before you change anything:
- Check the service definition that starts Node-RED and read the user it declares, or inspect the running process list for the Node-RED entry and its owning account.
- Compare that account with the owner and group shown by the directory listing of the certificate path.
- If ownership looks right but access still fails, check group membership and, where the system supports them, access-control-list entries on the file and its parents.
Changing ownership to pi:pi is correct only when Node-RED actually runs as pi. Assigning the wrong account hides the problem or creates a new one.
Inspect the path with ls -l #
From the certificate directory upward, list each level. In the ls -l output, the first field encodes the object type and three permission triplets for owner, group and others. For a directory, the execute bit means traversal: without it, the runtime account cannot pass through that directory to reach anything below, regardless of the file's own bits. For a file, read permission is what the open call needs. Tools that print the permission decision for every path component at once show you exactly which hop denies access.
Worked example: a PKI key file the service account cannot read #
Inputs, and where each comes from: Node-RED's data directory defaults to $HOME/.node-red (documented on the node-red-contrib-iiot-opcua package page), and node-opcua builds its PKI store under that data directory; the issue discussion of the OPC UA node shows the same structure as a .config folder containing a PKI tree, as in /usr/src/node-red/.config/node-opcua-default-nodejs/PKI. Suppose the service runs as the account node-red, and the failing path from the error is the private key under that PKI store.
The rule in words: opening a file requires execute (traverse) permission on every parent directory plus the needed permission on the file itself. A typical key file carries 0600 (owner read and write only), and a directory that carries 0700 admits only its owner.
The arithmetic, written out: the PKI directory shows drwx------ root root, which is 0700: owner (7 = read 4 + write 2 + execute 1), group (0), others (0). The runtime account node-red is neither owner nor in group root, so its effective access is the others triplet, 0, meaning no traverse. The open on the key below it fails before the key's own 0600 bits are even evaluated.
The result: the denial sits at the PKI directory, not at the key file.
The decision, with its threshold: grant the runtime account ownership of the certificate tree it is meant to manage. The fix is a chown of the PKI directory (and the key file) to node-red, after which the directory effectively reads 0755 or 0700 with node-red as owner and the key stays at 0600. If ownership must stay with another account, instead grant group read on the certificate files (0644) and group execute on the directories (0755) and add the runtime account to that group. Both paths give the process exactly what it needs; neither widens access to unrelated users.
Apply the targeted fix #
Decide first who should own the certificate material. If the Node-RED runtime account manages the PKI store, assign ownership of the affected directory or file to that verified account and its group. If ownership must not change, grant the runtime account the minimum access: read on certificate files, execute on their parent directories, and nothing more on private keys than the key's intended owner or group already has.
Avoid recursive permission changes unless every item under the target has been reviewed. A PKI tree mixes public certificates, which can be world-readable, with private keys, which must not be. The reported workaround of a recursive 777 change does clear the denial, but it grants every account on the host write and traverse access through the whole tree, wipes out the distinction between public and private material, and never establishes which permission was actually missing. Treat it as a throwaway diagnostic on an isolated test machine, not as the remedy. For a production host, keep the private keys locked down as part of hardening the OPC UA server that exposes your PLC tags; article:harden-a-node-red-opc-ua-server-exposing-plc-tags covers that policy.
Verify the deploy and the running state #
Re-check the corrected file and each parent directory from the runtime account's point of view, then deploy again and read the log. Two things must pass: the deploy completes without the permission-denied message, and the OPC UA server reaches its expected running state afterwards. A deploy that succeeds while the server fails at startup has not fixed the cause.
If a second path now fails, repeat the same diagnosis on it. The deploy stops at the first inaccessible object, so a chain of files can surface one denial at a time. Correct each named path individually and leave the permissions at the narrowest setting that passes both checks.
What to carry back to the cabinet #
The number that decides this fault is the effective permission triplet the runtime account sees on each path component: any 0 in that triplet at a directory blocks traversal, and a missing read bit at the file blocks the open. Get the path from the error, the account from the process, the truth from the listing, and fix one path at a time. The blanket change is never the answer on a host that holds production key material.
Questions asked
Does Node-RED always run as the default login user on the plant PC?
No. Linux checks file access against the identity of the running process, not the account open in your terminal. A Node-RED service started by systemd can run as a dedicated service account while you are logged in as an administrator. Check the service unit or the process list for the actual runtime user before changing any ownership or permissions.
Can I fix the OPC UA permission error with a recursive 777 change?
It removes the denial, but it grants every account on the host read, write and directory traversal across the whole certificate tree, including private key material. The targeted fix is ownership or a read grant for the verified runtime account on the specific path the error names. Use the blanket change only on an isolated test machine, never on a host that holds production keys.
Why does a file look readable but the deploy still fails?
Reading a file requires execute permission on every parent directory plus read permission on the file itself. If an intermediate directory denies traversal to the runtime account, the open fails even though the file's own permission bits look fine. Tools that print the permission for each path component show you which hop is blocked.
Where do node-red-contrib-iiot-opcua and node-opcua keep certificates?
Node-RED's data directory defaults to $HOME/.node-red, and node-opcua builds its PKI store under that data directory, for example a .config folder containing a PKI tree with trusted and rejected certificate stores. The exact location depends on how Node-RED was installed and launched, so take the path from your error message or runtime log rather than assuming the default.
A second file fails after I fix the first one. Is that normal?
Yes. The deploy stops at the first inaccessible object, so correcting it can reveal the next one. Re-run the deploy, read the new error path, and repeat the same targeted check and grant until the OPC UA server reaches its running state. Fix each named path individually rather than widening permissions on the whole PKI tree.