FAQ 2: How can I run multiple instances of Node-RED on the same server device?

Published: | Updated: | by Julian Knight Reading time ~2 min.
📖 Kb | 📎 Development | 🔖 Node-RED, FAQ

There are all sorts of reasons to want to run more than a single instance of Node-RED and several ways to do it.
  1. Use the command line settings to point to a different userDir folder.

    node-red -u /data/userDirectory

    That lets you use different flows and configuration settings but only allows a single version of Node-RED.

    You still install Node-RED in the “standard” way, globally. While this is generally simpler for complete beginners, it can lead to complexities later on. You should understand the strengths and weaknesses of npm global installs.

  2. Install the Node-RED npm package locally rather than globally.

    This gives you not only the features from 1 but also allows you to run different versions of Node-RED in parallel. The alternate-node-red-installer shows you how to do that.

    It also removes the need to install Node-RED globally which can lead to unexpected security issues.

    This is also the “Node.JS way” and likely to be a more welcome approach for organisations and teams that run other Node.JS services and systems.

    While slightly more complex to think about initially, especially for Node.JS beginners, it helps you understand how Node.js works, is easier to work out where everything is kept and is likely to be easier to maintain in the longer term.

    I use npm’s script capability to make things really easy to start manually. Here are some examples. Note that I always make the userDir folder a sub-folder of the master project folder (where Node-RED itself is installed). Keeps things neat and makes it trivial to backup the whole thing.

        "scripts": {
            "start": "node node_modules/node-red/red.js --userDir ./data",
            "start2": "set DEBUG=express:* & nodemon node_modules/node-red/red.js --userDir ./data",
            "inspect": "node --inspect node_modules/node-red/red.js --userDir ./data",
            "log": "sudo journalctl -u node-red -f -n 0 -o cat",
            "update": "npm install --unsafe-perm --production node-red",

    So you can start manually using npm start and start with debugging port active using npm run inspect

  3. Run Node-RED in a container such as the Docker container.

    Allows multiple versions of Node-RED along with different configurations and supporting software and services.

    However, this comes at the cost of significantly greater complexity and resource overheads. Unlikely to be worth doing except in specific circumstances & needs a reasonable level of understanding of how Docker works.

You will realise that I much prefer method 2 for all of my own installations. That’s why I wrote the alternate installer which goes some way towards making installations easier and more consistent.

For running Node-RED on system startup, please see the Starting Node-RED on boot page in the docs.

comments powered by Disqus