# How can I restart NR after crash (Windows)

**URL:** <https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914>\
**Category:** General\
**Created:** [31 July 2024 17:41 UTC](https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914 "2024-07-31T17:41:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [31 July 2024 17:41 UTC](https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914/1 "2024-07-31T17:41:34Z")

</div>

Hi, my work is based on node-red-contrib-kodi which unfortunately has bugs and authos gave up on updating it. These bugs makes NR crash, so I'm looking for a way to restart NR after crashing occuring under DOS, how can I get aware that NR quitted to restart it? I guess the beast way is to use a batch file.  
Thank you a lot for your suggestions

---

<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:** [31 July 2024 18:12 UTC](https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914/2 "2024-07-31T18:12:35Z")

</div>

> [@GiovanniG](#):
>
> I guess the beast way is to use a batch file.

Much better running it as a service. Search forum for `nssm`.

A service can have recovery options  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/55fb35c2139d3116090ae16f050934f27bc9c625.png)

PM2 is also an option folk use instead of a true service.

---

<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:** [31 July 2024 19:50 UTC](https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914/3 "2024-07-31T19:50:58Z")

</div>

I use PM2 to run my dev instance of Node-RED on Windows. One of its advantages is that you can get it to auto-restart when particular files change which is good for development in Node-RED.

The other advantage is that PM2 handles logs for you in a rather more predictable way than Windows.

Of course, it is possible to combine running PM2 as a service or indeed, simply start it using the Windows task scheduler.

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [2 August 2024 11:47 UTC](https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914/4 "2024-08-02T11:47:29Z")

</div>

Thank you mates for answers, I've found PM2 a very convenient way, quickly, to use it under Windows I used the following commands:

npm install pm2 -g  
npm install pm2-windows-startup -g  
pm2-startup install  
pm2 start C:\Users\<USER-NAME\>\AppData\Roaming\npm\node\_modules\node-red\red.js (use your path)  
pm2 save

---

<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:** [16 August 2024 11:47 UTC](https://discourse.nodered.org/t/how-can-i-restart-nr-after-crash-windows/89914/5 "2024-08-16T11:47:37Z")

</div>

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