I got problem to create a schedule task on windows 7 to run Node-Red on start

Hi, I tried to create a schedule task on windows start to run Node-Red. But I had error message said "There are currently no logon servers available to service the logon request." Therefore, the task were failed to start. However, the task still can be forced to run when I go to "Task Scheduler."
Please help. Thanks

Can you share your scheduled task settings please so we can see what is wrong.

Hi, thanks for reply, here is my scheduler setting screen capture below, I am sorry, my system language is Chinese, but I try to translate some keywords:

I also tried to create a service to auto start Node-Red as the command below, but the service cannot be started successfully, can anyone help? thanks
sc create NodeRedService start= auto binPath= "C:%HOMEPATH%\AppData\Roaming\npm\node-red.cmd" DisplayName= "Node-Red Server"

I use
NSSM - the Non-Sucking Service Manager

I use it to run multiple instances on ports 1880, 1881, 1882, ...

I set the following...

  • Program - node-red
  • Arguments -u c:\nr1881 -p 1881
  • User domain\user
  • Password supersecret

Thank you so much for help. I tried to setup without install other plug-in. I'll try it though.
Thanks again for help.

Nssm is not a plug in. It is a Windows application that hosts non service applications as a service for background running.

You download it. Run it as administrator, enter the values, press a button and you have a service.

Writing a service is far more involved otherwise.

Many thanks for your help. I finally use NSSM as you suggest, and it works fine for me. I am still wondering why cannot manually create service.

I would start by changing the security options to run when the user is logged in and the trigger to be on login.

Then you should be able to see whether Node-RED will start with the schedule. If it won't, you need to make sure that you are capturing the log output (stdout and stderr) to a file (or you can use something like PM2 to do that for you).

Once you know that NR will actually start, you can change the settings. Note that with the settings you showed, NR won't have access to any network resources which might be a problem. You should give the user password to the schedule so that it gets full access - I strongly recommend setting up a separate user for this if you want to use this in any kind of "production" capacity (as you would with a Linux install).

Many thanks for your great help and explanation. I also thought the failure would be caused by user logon or not. But how can I restart the service without login the system. Supposed the server restart because some reasons, and hence I need NR service auto restart as well with no one to login the server. I have tried many times do set up various user login conditions in scheduler, but all of them won't work. Now NSSM did work for me, but I'm still wondering why and where I was setting wrong.

The Windows scheduler isn't as comprehensive as the Linux systemd service. As you can see from your settings tab, the scheduled job will only attempt to restart 3 times trying once per minute. You can adjust that somewhat but the settings are fairly course.

In addition, I'm not sure (because I've never tested it) how well the scheduler understands tasks started from a command shell - which is what you are doing when you start a Node.js process the normal way. This is what NSSM changes, taking the process out of a normal shell and integrating to an actual Windows service which is better at handling background conditions.

As mentioned, you could instead use something like PM2 which creates its own service environment - that has its own advantages and disadvantages.

Bottom line is that Windows isn't the best (in my opinion and that of many others) at running services, it has too many overheads and too little control. Linux is much better at that but much poorer (generally, for many people) as a desktop.

I do development on Windows desktop but run services on Linux typically.

However, if a Windows machine is all you have as a server, here are your top choices:

  • Use NSSM to convert to a service
  • Use PM2 or similar to wrap the Node-RED process. Has the disadvantage of the overheads of PM2. Has the advantage of taking much better control of logs.
  • Use IIS and IISNODE to run Node-RED behind Windows' web server. This is how you do it if, for example, you want to run Node-RED cheaply on Microsoft's Azure cloud platform. But it works OK on Windows server and desktop too. Has the added advantage of being able to take advantage of IIS's web security features. It is, however, a little more complex to initially configure.

Thank you so much for detail and helpful information. It does help me a lot.
And I'll try IISNODE, it seems another interesting topic. Thanks.