# Running node red as a service\_Error

**URL:** <https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619>\
**Category:** Industrial\
**Created:** [6 October 2022 05:23 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619 "2022-10-06T05:23:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)\
**Post date:** [6 October 2022 05:23 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/1 "2022-10-06T05:23:45Z")

</div>

Hi,  
I need to run node red as a service on windows .Followed all the instructions provided in the other posts pertaining to the same topic , but getting an error as below:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/3/534174ea0e79c227edbe5cae01e4fcedc22d79a7.png)

And yes ,was trying to install nssm from 64 bit package since my system has a configuration of windows 10 , 64 bit.

Please help!.

BTW..any alternative to nssm or a way to run node red without the command prompt window open ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [6 October 2022 08:23 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/2 "2022-10-06T08:23:58Z")

</div>

Double check the path of the startup js file. I can see a double-backslash in there - not sure if that indicates something might be wrong with it.

As for starting without the extra command window. You can use the Windows Task Scheduler to start Node-RED before a user login. To do that, you either have to run it as SYSTEM or provide a user id and password. If you need more control, you could try using PM2 as well.

Overall though, running as a service is generally the best idea if you need Node-RED to run continuously.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [6 October 2022 08:54 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/3 "2022-10-06T08:54:01Z")

</div>

dont run `nssm` from desktop as it will be forever more locked by the service (it actually runs from the desktop)

At a guess, you downloaded nssm - maybe it is blocked by windows?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/63eeb39ae420a058cbaa69bd881ba65751f1335b.png)

Now assuming you are running this as a service with the `service` account (default) then the `service` account will NOT have access to `c:\users\rejoekoshy\xxx`

So move `nssm` to a neutral location (e.g. something like `c:\node-red\`)

Additionally, i assume user `rejoekoshy` is your setup account and will NOT normally be logged in? The default `npm` global location is global only to the user (not the system) - so i would recommend a non global install of node-red to somewhere the `system` account has access (e.g. `c:\node-red`) and then NSSM and node-red are in the same directory.

---

<div class="post-metadata">

**Author:** ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)\
**Post date:** [8 October 2022 07:09 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/4 "2022-10-08T07:09:17Z")

</div>

Hi,  
Could not install nssm due to repeated errors and hence had to resort to another scheme .I wrote a batch script to run node red (with the command window hidden) and hooked it with the start up process of the system.

.bat file script --- "ECHO ON  
ECHO Starting Node Red...  
node-red "  
.vbs file script (to run with command window hidden) --"Set WshShell = CreateObject("WScript.Shell")  
WshShell.Run chr(34) & "D:\OneDrive - Tega Industries Ltd\Desktop\RUN\_NODERED\nodered.bat" & Chr(34), 0  
Set WshShell = Nothing "

I am also looking to stop node red with a batch file command. Can anyone help me with the script?

---

<div class="post-metadata">

**Author:** ![Sineos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sineos/32/3440_2.png) [@Sineos](https://discourse.nodered.org/u/Sineos)\
**Post date:** [9 October 2022 08:49 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/5 "2022-10-09T08:49:59Z")

</div>

On Windows it is a real pain to identify the node process, especially if you have more than one. You could do something like this in powershell:

`netstat -ano | Select-String "LISTENING" | Select-String "1880" | ForEach-Object {$_.Line.split()[-1]} | ForEach-Object { Get-Process -Id $_} | Stop-Process`

This will find the process that is listening on port 1880 (default NR port) and stop it.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 October 2022 16:03 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/6 "2022-10-09T16:03:11Z")

</div>

> [@Sineos](#):
>
> On Windows it is a real pain to identify the node process, especially if you have more than one

Not really, Node.js has a library for it. simply add `process.pid` to a global variable in settings.js

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 December 2022 16:03 UTC](https://discourse.nodered.org/t/running-node-red-as-a-service-error/68619/7 "2022-12-08T16:03:37Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
