Quick answer: to secure Node-RED, (1) generate a password hash with node-red admin hash-pw and paste it into the adminAuth block of ~/.node-red/settings.js so the editor needs a login; (2) protect dashboards and HTTP In routes separately with httpNodeAuth; (3) serve it over HTTPS, either with the https option in settings.js or behind a reverse proxy, and reach it from outside through a VPN rather than an open port 1880; (4) give MQTT a password, topic ACLs and TLS on port 8883; (5) set a credentialSecret and back up flows.json, flows_cred.json, settings.js and package.json. Then restart Node-RED and test the login from another device.
Out of the box, Node-RED has no login at all: anyone who can reach port 1880 can open the editor, read your flows, change what your relays do, and run code through Function and exec nodes. That's fine on a laptop, risky on a home network, and dangerous on the internet, where exposed Node-RED instances are routinely found by scanners.
| Layer | Default | After this guide |
|---|---|---|
| Editor and admin API | Open to anyone on the network | Username + bcrypt password |
| Dashboard and HTTP In routes | Open | Separate login (httpNodeAuth) |
| Transport | Plain HTTP | HTTPS |
| Remote access | Port forwarding (please don't) | VPN or authenticated reverse proxy |
| MQTT | Often anonymous on 1883 | Per-device users, ACLs, TLS on 8883 |
| Stored credentials | Encrypted with an auto-generated key | Encrypted with your own credentialSecret, backed up |
1. Add a login to the editor (adminAuth)
Generate a bcrypt hash of your chosen password (Node-RED 1.1 or newer):
node-red admin hash-pwType the password when asked; it prints a hash starting with $2b$08$. Open ~/.node-red/settings.js (on Windows: C:\Users\<you>\.node-red\settings.js), find the commented-out adminAuth block, and replace it with:
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2b$08$PASTE_YOUR_OWN_HASH_HERE",
permissions: "*"
}]
},Restart Node-RED (node-red-stop && node-red-start on a Pi installed with the official script, or sudo systemctl restart nodered) and reload the editor: you should now get a login screen. Want a second, read-only account for someone who only needs to look? Add another user with permissions: "read".
Never copy a sample hash from a tutorial: it belongs to a password someone else knows. If node-red admin hash-pw isn't found, install the admin tool with sudo npm install -g node-red-admin and run node-red-admin hash-pw.
2. Protect the dashboard and HTTP endpoints
adminAuth only protects the editor and admin API. HTTP In routes, and in a standard install the dashboard, are served separately and stay open until you add httpNodeAuth (one shared login for all of them):
httpNodeAuth: { user: "family", pass: "$2b$08$PASTE_ANOTHER_HASH" },Use a different password from the admin account, so people who use the dashboard can't edit flows. Static files served with httpStatic have their own httpStaticAuth option in the same format. For per-user dashboard logins, put the dashboard behind a reverse proxy or an identity-aware proxy that handles accounts.
Any HTTP In endpoint a device posts to should also validate its input (method, fields, value ranges) and, ideally, check a shared token header. "It's only on my LAN" isn't a security model: one compromised smart plug is on your LAN too.
3. Turn on HTTPS
Without HTTPS, your login password crosses the network in plain text. Two ways to fix it:
| Method | Good for | How |
|---|---|---|
| Node-RED's own HTTPS | One machine on your LAN | Point the https option at a certificate and key |
| Reverse proxy (Caddy, nginx, Traefik) | Several services, a real domain, automatic Let's Encrypt certificates | Proxy terminates TLS and forwards to localhost:1880 |
For a LAN-only setup, create a self-signed certificate (or use mkcert for one your devices can trust):
cd ~/.node-red
openssl req -x509 -newkey rsa:2048 -nodes -keyout privkey.pem -out cert.pem -days 825 -subj "/CN=nodered.local"Then, in settings.js:
https: {
key: require("fs").readFileSync("/home/pi/.node-red/privkey.pem"),
cert: require("fs").readFileSync("/home/pi/.node-red/cert.pem")
},
requireHttps: true,Restart, and open https://<pi-ip>:1880. Browsers warn about a self-signed certificate the first time; that is expected for a private cert, unlike a warning on a public site. If you use a reverse proxy instead, leave Node-RED on plain HTTP but bind it to localhost (uiHost: "127.0.0.1") so the proxy is the only way in.
4. Remote access: VPN, not port forwarding
Do not forward port 1880 on your router. Even with a password, you are exposing the editor to every scanner on the internet. Safer options, in order of simplicity:
- Tailscale or WireGuard VPN: your phone joins your home network privately and you open Node-RED as if you were at home. Nothing is exposed.
- Cloudflare Tunnel or a reverse proxy with an extra login in front of Node-RED, with HTTPS and
adminAuthstill enabled. - FlowFuse or another managed host, if you'd rather not run the security yourself.
5. Lock down MQTT: passwords, ACLs and TLS
Mosquitto 2.x refuses remote anonymous clients by default; keep it that way and give every device its own account:
sudo mosquitto_passwd -c /etc/mosquitto/passwd nodered
sudo mosquitto_passwd /etc/mosquitto/passwd esp32-kitchenRestrict what each account may touch with an ACL file (/etc/mosquitto/acl):
user nodered
topic readwrite home/#
user esp32-kitchen
topic write home/kitchen/sensor/#
topic read home/kitchen/cmd/#Add a TLS listener next to (or instead of) port 1883 in /etc/mosquitto/conf.d/secure.conf:
listener 8883
cafile /etc/mosquitto/certs/ca.crt
certfile /etc/mosquitto/certs/server.crt
keyfile /etc/mosquitto/certs/server.key
password_file /etc/mosquitto/passwd
acl_file /etc/mosquitto/acl
allow_anonymous falseIn Node-RED, open the mqtt-broker config node: set port 8883, tick Use TLS, add a TLS configuration with your ca.crt, and keep Verify server certificate on. Enter the username and password on the Security tab: Node-RED stores them in the encrypted credentials file, not in the flow.
Inside a trusted LAN, passwords and ACLs on 1883 are a reasonable start; TLS becomes essential once traffic crosses Wi-Fi you don't control or the internet. Full broker setup: install Mosquitto on a Raspberry Pi.
6. Protect stored credentials and back up properly
Passwords and tokens you type into config nodes are saved, encrypted, in flows_cred.json. If you don't set a key, Node-RED generates one and hides it in .config.runtime.json; lose that file and every stored credential becomes unreadable on restore. Set your own key in settings.js:
credentialSecret: "a-long-random-string-you-store-in-your-password-manager",(Changing it on an existing install re-encrypts credentials on the next deploy, so do it once and keep the value safe.)
Back up these files from ~/.node-red:
| File | Contains |
|---|---|
flows.json | Your flows |
flows_cred.json | Encrypted credentials (useless without the credentialSecret) |
settings.js | Login, HTTPS and all runtime options |
package.json | The list of installed palette nodes, so npm install can restore them |
.config.runtime.json | The auto-generated credential key, if you didn't set your own |
A simple nightly backup on a Pi:
tar czf ~/backups/node-red-$(date +%F).tgz -C ~/.node-red flows.json flows_cred.json settings.js package.json .config.runtime.jsonCopy the archive off the device (NAS, another machine, encrypted cloud storage). Test a restore once: unpack into a fresh ~/.node-red, run npm install there, start Node-RED and confirm the flows and connections work.
Version control: enable Projects (editorTheme: { projects: { enabled: true } } in settings.js) to commit flows to Git from inside the editor. Use a private repository, and never commit settings.js containing real hashes or keys to a public one.
7. Keep Node-RED and its nodes up to date
- Update Node-RED and Node.js regularly; on a Pi, re-running the official install script upgrades both.
- Install only the palette nodes you need, prefer ones that are actively maintained, and remove unused ones.
- Back up before a major update and read the release notes for breaking changes.
- Be careful with nodes that run shell commands (
exec,daemon): anyone who can edit flows can use them, which is exactly why the editor login matters. - Run Node-RED as a normal user, never as root.
Security checklist
| Check | Done when |
|---|---|
| Editor login | Login screen appears from another device; wrong password is rejected |
| Read-only users | Viewers have permissions: "read" |
| Dashboard / HTTP In | httpNodeAuth set, with a different password |
| HTTPS | Editor loads on https://; plain http:// is refused or redirected |
| Remote access | No router port forward to 1880; VPN or authenticated proxy instead |
| MQTT | No anonymous access; one account per device; ACLs; TLS on 8883 where needed |
| Secrets | Tokens only in config nodes or env variables, never in Function code or exported flows |
| Backups | credentialSecret stored safely; nightly archive copied off-device; restore tested |
| Updates | Node-RED, Node.js and palette nodes current |
| Physical safety | Critical equipment has local interlocks, not just a dashboard button |
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| Node-RED won't start after editing settings.js | Syntax error (missing comma or bracket) | Run node-red in a terminal to see the line number; check commas between blocks |
| Login always says "Login failed" | Hash pasted with spaces or truncated; wrong username | Regenerate with node-red admin hash-pw and paste the whole string |
| Locked out of the editor | Forgotten password | Edit settings.js on the device, put in a new hash, restart |
ENOENT on startup after enabling https | Wrong certificate path | Use absolute paths and check file permissions for the Node-RED user |
| Dashboard still opens without a password | Only adminAuth set | Add httpNodeAuth and restart |
| "Credentials could not be decrypted" after restore | Different or missing credentialSecret / .config.runtime.json | Restore the original key, or re-enter the credentials |
| MQTT node stuck "connecting" on 8883 | CA file wrong, hostname doesn't match the certificate, or port blocked | Test with mosquitto_sub --cafile ca.crt -p 8883 -h <host> ...; the certificate CN/SAN must match the host name you use |
| Missing nodes after restore | Palette packages not reinstalled | Run npm install in ~/.node-red, then restart |
FAQ
Does Node-RED have a password by default?
No. The editor is open until you configure adminAuth in settings.js.
Where is settings.js?
In the Node-RED user directory: ~/.node-red/settings.js on Linux and a Raspberry Pi, C:\Users\<you>\.node-red\settings.js on Windows, and /data/settings.js in the official Docker image. The startup log prints the exact path.
Is it safe to expose Node-RED to the internet with just a password? It's much better than no password, but still not recommended. Use a VPN such as Tailscale or WireGuard, or an authenticated reverse proxy with HTTPS in front of it.
Does adminAuth protect the dashboard?
No. Use httpNodeAuth for the dashboard and HTTP In routes.
How do I reset a forgotten Node-RED password? Generate a new hash, replace it in settings.js and restart. Anyone with shell access to the device can do this, so protect the device itself too.
Next steps
- Install Node-RED on a Raspberry Pi 5 or on Windows, if you're starting fresh.
- Node-RED with Mosquitto: publish and subscribe: the MQTT basics behind section 5.
- MQTT troubleshooting: rc=-2 and rc=5: what to check when devices stop connecting after you add passwords.
- Reliable Node-RED flows with subflows and Catch nodes: the next step after securing it.
- Node-RED complete guide.
Official reference: Securing Node-RED and the Mosquitto configuration manual.




