Node-Red stopped... sort of

I have Node-Red 0.18.4 running under NSSM. A few days ago it stopped mysteriously, and we became aware because it stopped logging to MSSQL. However, I could still see the project through the web editor. New error messages were not coming in. No event took place in the Windoes Event Viewer at the moment logging stopped. I was wondering: under NSSM, where do event and error logs go? I've tried redirecting in the NSSM service editor to a .log file I've created, but they remain empty after restarting the service... Just trying to figure out how to diagnose the problem if it happens again.

what if you stop Node Red from running as a service temporarily and just run it from the command prompt by typing node-red

Thanks for responding... Well, I am trying that, but it's created another knotty problem. I'm logged on as a different user than the original creator. When I launch node-red manually, it uses my user directory instead of the one the project was installed under. So, all the flows are missing from the project at launch. I'm trying to figure out how to manually launch node-red but specify a different directory, the one where the flows and nodes really are.

Also, another reason I'm trying to manually start node-red is because I'm getting an error message "1% START is not a valid win32 application" when I type nssm start node-red service. I am able to manually start node-red though, so I think there's some issue with the nssm configuration. But it'd be good to see my flows again.

I tried using the command "node-red start --userDir (directory)" but the flows are still gone....

This version is 3 years old at least. If something is broken, it is possible that some other app or library has updated and so this outdated version has an issue.

What version of that are you using - has that been updated? If not, you should do so.

You define that in the configuration of your service. I found this via Google search:

you cant simply log out from your account and log in with the account credentials the NSSM node-red service is run ? and run node-red with the correct account ?

ps .. you have administrative rights with your account ?

Thanks! I had four problems but now only have two:

(1) my flows seemed to be missing because I logged in as someone other than the creator and it was using my user directory instead of his. Easy to fix with 'node-red -u "path to project"'. It is now running with the original flows, so I've verified that node-red should be able to run the project.

(2) but why is it rejecting being run from NSSM as not a valid Win32 application?
(3) what caused it to stop in the first place?

(4) assuming I can get NSSM to launch node-red again, how to view log files? well I found the answer, when using the NSSM GUI to configure the service, you can direct output to a file of your choice with the arguments field ("-u userpath > pathtologfile"). That part is working. But to answer problem (3), I'll need to catch it in a running/not running state and examine that log file, which wipes when node-red restarts.

what have you tried ?
a quick search on the forum reveals many results for NSSM configuration for NR.

I think its best for debugging to run it from the command prompt first and then set it up as a service

1 Like

I'm logged in as an admin and I'm running a DOS window as administrator. From there, I go to where NSSM is and type "nssm install node-red", and set the application path and user paths. After pressing edit service, I try to run it from DOS with "nssm start node-red" and it generates the error:

node-red: START: %1 is not a valid Win32 application.

If I try to Start the NSSM-created node-red service from services.msc, I get the error message:

Windows could not start the node-red service on the local computer. Error 193: Oxc1.

I tried making sure that there were no spaces or files with the same name as the path. I also checked the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ and there were no listed path discrepancies. It's baffling. The only different thing is that I'm logged in as a different user, but I have full admin rights.

i think thats not correct .. it has to be
nssm install Node-RED "c:\Users\\"%USERNAME%"\AppData\Roaming\npm\node-red.cmd"

i think with your command you are just defining the name of the service but dont give it the path to the file to run.

Follow this article made by one of the developers of Node-red

Tried it, but it didn't work. Also tried double-escaping all paths \ \ but that didn't work. Tried removing old service and rebooting, installing new service, still doesn't seem to like the path.

dont know Tony
i tried it just now, following the article and it works for me .. tried the 32bit
Version : nssm-2.24-101-g897c7ad\win32>

i also stopped the service from Windows 10 Services and run nssm edit Node-RED to confirm
These are my settings


At this point I've moved on to PM2 with PM2-windows-service. NSSM just wouldn't work.

Lots of people have been using NSSM for a long time so it is very unlikely that it was nssm that was the problem. It is clear that you had a number of issues and that things hadn't necessarily been kept current. You also didn't pay attention to the logs until it was a bit late. There are undoubtedly ways to rotate the logs when the service restarts.

There are also alternative ways to run node.js apps reliably under Windows. It rather depends on the requirements you have. Certainly, using Windows as a server is, in my experience, nowhere near as convenient as using Linux. One excellent way to run Node-RED in production on either platform is behind a reverse proxy. On Windows you can run IIS with an extension that ensures a node.js app is kept live so that you don't have to mess with running it as a service directly. This is typically a lot more efficient.

Also, you probably want to be using jessety/pm2-installer: Install PM2 offline as a service on Windows or Linux. Mostly designed for Windows. ( rather than pm2-windows-service as that hasn't been updated in 4 years.

Please to take care to use current applications and services, you really are wasting your own time and other people's otherwise.


@tony1 NSSM works. Here is a batch file i patched together to simplify the installing as a service process (hope it helps). Just run it from the root directory where the NSSM .exe is located.

@echo off

:: BatchGotAdmin
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    del "%temp%\getadmin.vbs"
    exit /B

    pushd "%CD%"
    CD /D "%~dp0"

set /p SERVICENAME=type the service name: (leave blank if wanting default Node-RED)
set /p USERNAME=type username:

PING localhost -n 2 >NUL
ECHO Make temp directory
mkdir c:\temp
PING localhost -n 3 >NUL

ECHO Install Service
nssm install Node-RED "c:\Users\%USERNAME%\AppData\Roaming\npm\node-red.cmd"
PING localhost -n 3 >NUL

ECHO AppDirectory
nssm set Node-RED AppDirectory "c:\Users\%USERNAME%\.node-red"
PING localhost -n 3 >NUL

ECHO AppParmameters
nssm set Node-RED AppParameters "-u c:\Users\%USERNAME%\.node-red > c:\temp\node-red.log"
PING localhost -n 3 >NUL

ECHO Service Description
nssm set Node-RED Description "A wiring tool for the Internet of Things"

PING localhost -n 5 >NUL

1 Like

Thanks, wish I'd read this but went ahead with pm2-windows-service because of time pressure. It does seem to be working, and it is for a 2016 Server machine running an older version of node-red. However, there is that drawback that it installs under user appdata, but won't work unless you create a home on the system level (see NodeJS: PM2 Startup on Windows. How to deal with NodeJS app on Windows… | by Walter Accantelli | CloudBoost). Being new to this, I also feel into the trap of setting "watch:true" which creates intermittent restarting if files are being written to.

I love this on my dev machine. Makes development so much easier. But yes, not so good on a production machine :anguished:

I should also have pointed out that it is in fact possible to run node-red using the Windows Task Scheduler. That is a very flexible scheduler that lets you run tasks in many different ways.