Running Node-RED under Windows 10+

Please use this thread to provide and update tools and methods for running Node-RED on Windows (10+ and Windows Server).

NOTE: This FAQ should be read as an extension/update to the official documentation on running Node-RED under Windows.

There are 4 basic approaches to this:

  1. Run manually
  2. Run as a Service
  3. Run using Windows Task Scheduler
  4. Run via IIS (Windows web server)

1) Run Manually

As a node.js app, Node-RED can easily be run manually from the command line or a suitable shortcut. This runs under your logged-in user id and so inherits the same permissions.

You can also use PM2 which will help with auto-restarts, log management, etc.

Either way, consider altering the package.json file in your userDir (typically /Users/<userid>/.node-red) and adding start, restart and logs scripts so you don't need to remember each time how to run things. A default install (e.g. npm install -g --unsafe-perm node-red) will install a system-wide command node-red.

This method is good for developing flows for running elsewhere and to use Node-RED as a utility locally.

2) Run as a Service

3) Run using Windows Task Scheduler

4) Run via IIS (Windows web server)

... TBC ...

NOTES:

I recommend using a specific user id to run node-red if you wish to have it permanently running in the background. SYSTEM has a lot of access and might be abused. This is in line with my security recommendations for running node-red under Linux too.

If you simply want to run it periodically as a Windows app, I recommend using PM2 to run it under your current user id - you can use the package.json in your userDir folder to define some npm scripts to start/restart and show logs. You can also use a watch list for auto-restart after key file changes.

The other approach is to turn on IIS which is Windows' web server and it can be used as a reverse proxy. There is an extension for it that lets it manage node.js services directly. I need to dig out the name of that.

References:

Installation Notes

Node.js

The official docs mention using Chocolatey to install node.js - this can not really be recommended any more unless you happen to already be invested in that tool. It will probably work fine but is no longer the best way for modern versions of Windows.

Instead, either install using the installer from the Node.js official website or use the now native winget tool if you want a command-line installer.

To update node.js, either re-run the installer or use winget upgrade nodejs-lts (which will update to the latest version of the latest LTS version). There are also packages in winget for current and nightly builds. You can also specify a particular version but at the moment, you have to go find the correct version string. Winget also has a 3rd-party UI tool in case you want it.

Note that newer versions of Node.js for Windows include the windows-build-tools so you don't need to do that separately.

This topic was automatically opened after 3 minutes.

With the latest releases of the Windows 10 & 11, the Windows Subsystem for Linux (WSL) now has the capability to not only run Linux graphical applications but it also supports the use of systemd.

So there is now an alternative way of running Node-RED under Windows, not only with a manual start as previously, but as an auto start the same way as running it on Debian, Rasbian or Ubuntu.

To turn on systemd. Create a file called /etc/wsl.conf and add:

[boot]
systemd=true

and restart WSL.

Though I've not tried it, Dave's excellent Node-RED Raspberry Pi install script should work just fine. My alternate installer also works and comes with an example systemd service file and instructions for installation.

In order for this to work when you boot your PC, you need to create an entry in the Windows Task Scheduler. This blog post should work for that: WSL 2: Run Ubuntu Services on Windows 10 Startup - TechBrij.

Note that Windows lets you start things at different points in the startup and login process and you can choose to run WSL under the SYSTEM account (probably not really a brilliant idea) or a user account. If a user account, you can decide whether to run before login (and whether to store the password - whether you do or don't changes what access Node-RED would get to the system) or after login.

So plenty of options.

3 Likes

Hi,
I'm running multiple Node-RED production applications on Windows10 and WindowsServer virtual machines. All these run as services using NSSM and also redirect std and err output to a log file. I use a bunch of custom bat files to manage start/restart/stop the service, but I can also manage it from the standard windows "services" tool. Node-RED runs under a specific user.
This setup has served me well, much better than simply scheduling the execution via Task Scheduler. I always installed nodejs LTS with the installer found on nodejs website.
Good to know that systemd has become a thing for windows too! I'll give it a try as soon as I can.

1 Like