Installing Node Red
Node-Red is a node application and before you Install node red you will need to first install node. Here are the instructions:
Then you can Install node red on Windows and Linux (including raspberry pi) using:
npm install -g --unsafe-perm node-red
Using the -g option adds the node-red command to your path. On linux you will need the sudo option. See the documentation.for more details.
Node-Red on Pi Notes:
Node red is already installed on Raspberry pi but npm (node package manager) isn’t.
You may need to upgrade node-red which you can do by doing an install using npm but you will need to install npm first. This you can do using:
sudo apt-get update sudo apt-get install npm
Note: npm install failed on my pi and I had to use this command first:
sudo apt-get install -y build-essential
You can check the versions of npm,node and node-red using:
npm -v node -v node-red --help
However Raspberry pi provide an install script which can be used for installing and upgrading node-red on the pi and I recommend using it. The procedure for download and using it are here.
I recommend you copy the command from the page and paste it into your command prompt.
Starting Node Red
To start node red on Windows go to a command prompt and type:
if you installed node-red using the -g option.
Note: you may need to change into the node directory.
If it fails you can use:
Firstly running node by typing node may not work as apparently node is a short cut to nodejs and the short cut may not be present.
In addition there appears to be a naming conflict with another package. see this explanation
The screen shot show how to create the symbolic link
Now that node is working you can run node-red.
Type node-red at the command prompt
. If that doesn’t work it’s probably because the link isn’t configured as shown above. You can try the alternative.
As shown below
At the top of the screen you can see the version of node and node-red that you are using and the location of the flows..
At the bottom of the screen it tells you the url to use to access the node-red web admin interface which you use to create your flows.
This console stays open and you will find it useful as when you start creating flows as you will see log information appearing there.
Starting Node-Red as a Service
On Raspberry pi you can also start node-red using:
which starts node-red as daemon.
to stop it use:
and to view the log files type
Starting Node-Red on Boot
If it isn’t already configured you can automatically start node-red on system start by using the command:
sudo systemctl enable nodered.service
and disable it using:
sudo systemctl disable nodered.service
When running on start up you can stop it using the node-red-stop command and restart using node-red-start command.
If you want to load node-red on startup with a different settings file than the settings.js you will need to edit the file /lib/systemd/system/nodered.service.
un-comment the line ExecStart if not already done and the Environment=”NODE_RED_OTPIONS=-v” line to something like:
Node-Red Start Process Overview
When node-red starts it first loads the settings file settings.js which is used to set the admin port, user directory, and flows file etc. The start process is illustrated below.
Node-red uses a settings file called settings.js.
On Linux it is located in the /usr/lib/node_modules/node-red/ folder by default. on Windows it is located in c:\node-install-directory\node_modules\node-red\ .
On Linux the settings.js file is copied from the /usr/lib/node_modules/node-red/ folder to your .node-red folder in your home directory when you start node-red, and there is no settings.js file present.
You can create your own settings file and customise it either by copying the existing file or using the file available from Github here.
To use your own settings file use the -s switch when starting node-red e.g.
node-red -s mysettingsfile.js
Important -If you place a settings.js in the .node-red folder then that will be used by default.
The documentation here takes your through the settings file in detail.
The .node-red Folder
On both Windows and Linux user settings and flows are stored in the .node-red folder. This folder is located in the users home folder.
E.G For user steve on windows and on Linux
/home/steve/.node-red ……….. Linux
Node-red Flows Files and Storage
Node red flows are stored in a .json file in the .node-red folder.
By default this file is called flows_machine_name.json. For example my windows machine is called ws6 and the default flows file is called flows_ws6.json.
New modules that you install are installed under the node_modules folder in the user directory which by default is .node-red.
Useful Command line Options
Node red has a very limited number of command line options. Use:
The -v switch turns on verbose mode.
The -p switch will let you change the port that node-red admin interface uses.
You can use this option to quickly and easily run multiple instances of node-red.
In version .20 a safe mode has been added to allow you to start node-red without deploying any flows.
This is very useful if a flow is stopping node-red from running.
To use a different flow file than the default you can use
Because you haven’t specified a settings file it uses the default settings file.
Running Multiple node-red instances
It is possible to run multiple node-red instances on a single machine.
To do that you will need to give each instance a different admin port and also a different user directory or alternatively create and use a new settings file.
You can do this using the -p and -u switches when starting node-red e.g
node-red -p 1881 -u user1
the admin port is 1881 and the user directory is user1 the flow file name uses the default flow name.
Note: If you don’t use a different user directory then they will all use the same flows file which could result in conflicts.
If you create a new settings file e,g mysettings.js you can then edit the line starting with flows and remove the two forward slashes.
// flowFile: my’flows.json’,
You could also change the port by editing the line near the top of the file
uiPort: process.env.PORT || 1880,
uiPort: process.env.PORT || 1888,
To use port 1888
You then use the command:
node-red -s mysettings.js
to start the flow.
You could also use the command
node-red -s mysettings.js -p 1889
to use a different port.
Video Node Red Flow and Startup Files
========>How to use the Admin Interface, nodes and flow basics.
Related Tutorials and Resources:
P.S. just saw the reference to starting services on boot – so wondering if I can simply duplicate that to start the two instances at the same time.
Don’t know but looks interesting I will have to give it a try.I think you will need to files node-red.service and node-red2.service and specify the port in the node-ed options
If you try it before me let me know
I got this response from the node-red forum:
“You need a service file for each instance. Then you can individually control them, and they will individually restart in the case of crashes.”
Thanks so much for the guides – followed its to get another instance running: duplicate settings file, different port, mapped to different subdomain (nginx). Now trying to figure out how I can have it start automatically like my primary instance (that was installed via the pi script, running as a service).
Have you seen this
Thanks Steve for your details,
also seems some points have changed. Just noticed my installation runs a newer version with these options:
Usage: node-red [-v] [-?] [–settings settings.js] [–userDir DIR]
[–port PORT] [–title TITLE] [–safe] [flows.json]
node-red admin [args] [-?] [–userDir DIR] [–json]
-p, –port PORT port to listen on
-s, –settings FILE use specified settings file
–title TITLE process window title
-u, –userDir DIR use specified user directory
-v, –verbose enable verbose output
–safe enable safe mode
-D, –define X=Y overwrite value in settings file
-?, –help show this help
admin run an admin command
For this, using another port with -p 2000 (for example) is fine, but passing a ‘userflow.json’ doesn’t seem to be possible, or is it tricky?
Also with the newly introduced ‘projects’ you have to look closer.
If I use the default port with ‘node-red’ only, I get:
12 Jan 21:18:23 – [info] Node-RED version: v3.0.2
12 Jan 21:18:23 – [info] Node.js version: v19.3.0
12 Jan 21:18:23 – [info] Linux 5.10.103-v7+ arm LE
12 Jan 21:18:28 – [info] Loading palette nodes
12 Jan 21:18:34 – [info] Dashboard version 3.3.0 started at /ui
12 Jan 21:18:35 – [info] Settings file : /home/pi/.node-red/settings.js
12 Jan 21:18:35 – [info] Context store : ‘default’ [module=memory]
12 Jan 21:18:35 – [info] User directory : /home/pi/.node-red
12 Jan 21:18:35 – [info] Projects directory: /home/pi/.node-red/projects
12 Jan 21:18:35 – [info] Server now running at http://127.0.0.1:1880/
12 Jan 21:18:35 – [info] Active project : redStuff
12 Jan 21:18:35 – [info] Flows file : /home/pi/.node-red/projects/redStuff/redStuff.flow.json
12 Jan 21:18:35 – [warn] Using unencrypted credentials
12 Jan 21:18:36 – [info] Starting flows
12 Jan 21:18:36 – [info] Started flows
12 Jan 21:18:36 – [info] [mqtt-broker:1826333333971f0] Connected to broker: mqtt://rpi:1883
Here NR works with a ‘project’ setting configured in previous NR usage.
Interesting, starting with “node-red -p 2000” not having ‘projects’ and it was not possible to enable it within the NR editor!
13 Jan 00:02:10 – [info] User directory : /home/pi/.node-red/projects/dMQTTdevices
13 Jan 00:02:10 – [warn] Projects disabled : editorTheme.projects.enabled=false
13 Jan 00:02:10 – [info] Flows file : /home/pi/.node-red/flows.json
The ‘Flows file’ names seems to be set by NR. As you can see in the startup options, there is no option for this. Note if the option “Project” is activated, how then the path name is built.
Is this the Github projects feature you are trying to use? It is something I’ve been meaning to look at.
Not sure about y Q “the Github projects feature you are trying to use?”
Can you give a link for what you have in mind?
Is it possible to install Node-RED on Windows NOT in the home folder?
My problem is, that from time to time Windows deletes the user folders and creates a new profile, mostly after an Windows update.
You should be able to simply copy the entire folder to another folder and run it from there. I haven’t tried it as I use node-red on linux. Let me know how you get on.
Thanks for helping to start with node-red … your pages are very good for a NR newbie like me.
After building the first flows and starting them with :1880/ui I noticed I can’t work on a second, different flow/project. Your mentioned method with a second port may work, but I can’t figure out where the first/current flows are stored.
I’m on an RPI and use the standard user ‘pi’. The directory .node-red hasn’t any new flows.json files. Also searching the complete /home directory doesn’t give any other.
Any further advice?
Sorry, my mistake!
I had loaded a flow from another application and defined it as a ‘project’. In the meantime I deleted this flow, but didn’t realize that the project is still in the .node-red directory.
All my new flows I defined are kept inside that ‘Project’.
I guess I can use this for the setup with multi port/session.
I think they might have changed the default naming scheme. However they should be stored in the .node-red folder.
Do a listing for *.json.
Because I have many flows that I work I I start them all by name so I use
node-red test.json -p 2000 //starts with test.json file on port 2000
node-red clients.json – p 2016 //
node-red // starts on port 1880 using default flow file
note when node-red loads it should show the flow file it is using with the complete path.
I think there is a typo on your site:
‘node-modules’ should be replaced by ‘node_modules’
Kind regards from
Tks for that I think I found them all
Hi, how to install .js file in NR?
Der Befehl “node-red” ist entweder falsch geschrieben oder konnte nicht gefunden werden.
Provided you have installed it then fo to the .node-red folder in your my documents folder and run it from there.Let me know how you get on.
I have created a copy of the .node-red folder and named it as .node-red-test. This allows me to have a separate instance for testing purposes. For each instance, I use a different command line:
– node-red -p 1881 -u c:/alberto/.node-red-test.
All works as designed, however, wondering how to update node-red on each of these instances. I guess that sudo npm install -g –unsafe-perm node-red will act only on the default .node-red folder, correct ?
I think if you run the command
npm install –unsafe-perm node-red
in the node-red-test folder it will update the one you want but I haven’t tried it.
My son is trying to install red node after successful install when he goes to run the program it opens up a text file and that’s all he gets he can’t do anything else, please advise, my son’s really bummed out because he’s building a project and he has done the physical part of it but he needs to add the electronic side, thank you.
Can you send a screenshot using the ask-steve page
I tried to install node-red and got this message: What went wrong, how can I avoid this?
I did not understand the information in the issue.
Thanks in advance
C:\Users\Frank>npm install -g –unsafe-perm node-red
npm WARN deprecated email@example.com: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\Frank\AppData\Roaming\npm\node-red -> C:\Users\Frank\AppData\Roaming\npm\node_modules\node-red\red.js
C:\Users\Frank\AppData\Roaming\npm\node-red-pi -> C:\Users\Frank\AppData\Roaming\npm\node_modules\node-red\bin\node-red-pi
updated 1 package in 21.166s
Not sure anything did go wrong it looks just like a warning, Is node-red running?
Thank you Steve,
after reinstall node-red seems to work. I got:
node –version ==> v12.16.2
npm –version ==> 6.14.4
Node-RED version: v1.0.5
in Win10 prompt and node-red message
“Server now running at http://127.0.0.1:1880/”
in terminal window. I hope thats fine to start?
Thanks for all you do. Your site is of great value.
For windows, I am trying to specify a nodes directory in that I have sub folders for all my “users” but I want them all to use a common folder for my nodes.
When I start up each unique instance of node-red, it is reading the settings files but complaining that it cant find the custom nodes.
Can you send me a screen shot of the message. Are there any permissions issues on the folders? When you say users are they accessing across a network?
Thanks for your site. I try to run 2 instances of node-red, one for the adults and one for the kids:-)
So, first my old instance is starting automatically with “sudo systemctl enable nodered.service”. This ist listening in port 1880. The second instance i started with “node-red -p 1881 -u kids”. All works fine, but how can I make this command autostarting like my first instance?
Hope you can give me a hand to solve that problem.
Assuming you are on Linux/Pi then I would try the pm2 script see
I would also use a separate JSON flows file using the -s kids.json option as it stops them changing the flows in the main instance.
It is actually on my to do list as I run several instances for testing and client flows.
Let me know how you get on or if you have any problems
Thanks for your reply. Will try it tomorrow, first i have to make a copy of my sd-card with a running configuration 😉
I suggest, that the command will be
pm2 start /usr/bin/node-red — -p 1880 -u adults
pm2 start /usr/bin/node-red — -p 1881 -u kids
pm2 startup systemd
Could that work?
Great site and very informative, I’ve been following for about a year and has helped tremendously!
One question about node-red settings.js. it’s not clear how to go about reloading the settings.js file.
after making changes. It seems that a simple [Deploy] of node-red flows wont do the trick.
Do you have to stop and start the node-red service ` service node-red start | stop| reload`
or is there any way you know of to reload the settings file without having to re-initialize node-red?
Glad you find the site useful.
There is no other way as far as I know but restarting node-red.
Awesome site and content Steve.
Very easy to follow for beginners like me and very very much appreciated.
Hi Steve, great website .
I got question regarding using Node-red to read data via Ethernet port from some TCP “slave”. Device I use (with Windows OS) has two physical Ethernet ports. Each port can be configured independently from the other ( IP address, DHCP or Fixed) . Can i read data from any of two physical Ethernet ports using Node red? I’m note quite sure how that part would work , Node red with two ports. Would appreciate any help or if you can point to some info.
Interesting question.The only ethernet node I could find is this
The tcp node would read the data but you wouldn’t know which port it cam from.
Sorry can”t be of more help.
I found your page hope you can help me. I have a synology nas and installed the node-red. My problem is only run it from console, and when close the console the node red is turning off too. For me what you write:
“Starting Node-Red as a Service
You can also start node-red using:
which starts node-red as daemon.”
not working, because the console show this: node-red-start: command not found
I found another page can start it with pm2 https://www.rs-online.com/designspark/installing-node-red-on-a-synology-nas but it isn’t working too. 🙁 After install pm2 the console show me the same message pm2: command not found. How can I run in the background the node-red? Please help!
Try using PM2.The instructions are here