Out of the box, Node-RED has no security—anyone who can reach TCP port 1880 on your machine can deploy and run arbitrary code! This is a significant security risk, which you should mitigate in either of a couple of ways.
One solution is to use a firewall to block incoming traffic to this port from anywhere other than the loopback interface (localhost). Windows, Mac OS X, and Ubuntu all come with built-in firewalls, but they may not be enabled by default.
Another choice is to configure Node-RED itself to respond to requests only from localhost. To do this, open the settings.js file that Node-RED created in your config directory. Look for the uiHost setting in a section that reads like this:
| | // By default, the Node-RED UI accepts connections on all IPv4 interfaces. |
| | // The following property can be used to listen on a specific interface. For |
| | // example, the following would only allow connections from the local machine. |
| | //uiHost: "127.0.0.1", |
If you uncomment the uiHost line and then start up Node-RED, it will accept connections from only localhost.
Either the firewall or uiHost option works fine as long as you’re working from the same machine than Node-RED is running on. If you want to access and use Node-RED remotely, you’ll need to set up authentication and you should invest in configuring HTTPS. The Node-RED project’s security page describes how to do this.[110]
With basic security out of the way, you’re ready to develop your first flow in Node-RED!