Multiple NodeRed Instances on different Ports - Linux/SystemD

I know this has been addressed because I've made it work in the past, so I apologize for rehashing an already discussed topic... but I can't seem to find the instructions again. I've tried multiple times using some of the other methods I've found to get this to work and have done nothing but break Node_Red repeatedly.

I have an AWS server and I need to run 2 instances of NodeRed on 2 different ports. I'm running Ubuntu and using SystemD to autostart Node-Red on boot.

The goal is to have 2 admin panels so that 2 different people can test and develop without having to boot up a second server with its own Node-Red install... and be able to point 2 different domains to the UI of those instances.

I'd like to avoid using PM2 if possible, as I used this method of autostart when I installed:

I tried the following instructions, but only managed to get an error saying it can't find red.js and Node-Red failed to boot:

So I've rolled back... fresh install of Node-Red... What's the easiest way to get 2 instances running on 2 different ports?

Thanks in advance.

What I do, is create two different directories and do npm i node-red in each one and then edit the settings.js file in node_modules/node-red so that they use different ports.

And then, in each directory, I launch two node-reds using a command like node node_modules/node-red/red -s node_modules/node-red/settings.js -u ./

This tells node-red to use the settings.js file found in the node_modules/node-red directory and to create a flow.json file in the current directory.

Use the command line options.

Command-line usage

Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR] [flows.json]

  -s, --settings FILE  use specified settings file
  -u, --userDir  DIR   use specified user directory
  -v                   enable verbose output
  -?, --help           show usage

You only need to install once then run a second, third, nth instance with different command line options.

1 Like

Typically I do ...

node-red -u /node-red-1881 -p 1881

Just noticed the -p option is missing from documentation (but it definitely works)

Perhaps documentation is out of date?

1 Like

Hi @Steve-Mcl, good point. The part to be updated is the result of the node-red --help, which would be:


I will fork the doc repository and try to submit a pull request.

Thanks for the reply. I've seen several posts regarding the CLI options...

I just can't seem to get those incorporated into the auto-startup option. I may not have been very clear in my post, sorry.

I am using systemd to auto-start the node-red service. Currently it starts 1 instance on port 1880.

I need it to also auto-start a second instance on port 1881.

I've tried copying the /lib/systemd/system/nodered.service, renaming it, modifying the internal settings to try and pull from different settings.js files... and then modifying those settings.js files to use different ports.

I've tried modifying the Environment line to include the options you've specified for the CLI.... but no matter what I try, it either tries to start a second instance on the same port, or throws some other can't find "red.js".

Am I over-complicating this by trying to use SystemD to autostart both... and maybe I should just write a script?

Show us your modified systemd script that tries to specify the settings and flow file.

1 Like

As long as your settings.js file is right, you can do this via an environment variable. I posted my setup a few days ago that showed how to do this via an environment file.


uiPort: process.env.PORT || 1880,


Obviously you can call this whatever you want.

# See
# If changing this file, run:
# sudo systemctl daemon-reload && sudo systemctl enable nrlive

Description=Node-Red Home Automation production (live) service
Wants=mosquitto.service influxdb.service


#Environment="NODE_OPTIONS=--max-old-space-size=128" "NODE_RED_OPTIONS=--userDir /home/pi/nrlive/.data -v"

# Environment variables file, overrides the Environment settings
# @See

# No path available here so make sure absolute folders specified
ExecStart=/usr/bin/node $NODE_OPTIONS /home/pi/nrlive/node_modules/node-red/red.js $NODE_RED_OPTIONS


# User/Group that launches node-RED (it's advised to create a new user for Node-RED)
# You can do : sudo useradd node-red then change the User=root by User=node-red



# Make Node-RED restart if it fails


# Node-RED need a SIGINT to be notified to stop

# Prevent this service changing the OS or /etc
# @See



# Environment variables file for running nrlive under SystemD
# Each line is a separate variable that will be available to the ExecStart
# and to the running process.
# @see
# Called from /etc/systemd/system/
# Which is linked from /home/pi/nrlive/systemd/nrlive.service

NODE_RED_OPTIONS=--userDir /home/pi/nrlive/.data -v
1 Like

@Colin I mentioned in my first post that I wiped everything and started fresh, so my systemd file is currently a wget from:

as instructed here:

I probably should have started with my modified file and asked for help, but nothing worked, and I wasn't even sure I was on the right track really.

@TotallyInformation Thanks for the post! I am pretty sure I can get that to work. I'll try first thing when I get back in the office tomorrow morning.

No problem. Just note that I don't use the standard installation of Node-RED. Instead I prefer to install to a "master" folder with a sub-folder containing the userDir. I'm sure you will be able to adjust according to your needs.