# How stop Node Red under Windows when started from pm2

**URL:** <https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888>\
**Category:** General\
**Created:** [3 November 2024 21:44 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888 "2024-11-03T21:44:23Z")\
**Posts on this page:** 8\
**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:** [3 November 2024 21:44 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/1 "2024-11-03T21:44:23Z")

</div>

Hi, I've a module which doesn't work in best way, and I need to stop manually NR to reset its queuem how can I do it by command line? there is no node-red-stop batch like on Pi.  
I've started NR under pm2 to ensure it works even in case of faults, should I use pm2 commands to 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:** [3 November 2024 22:08 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/2 "2024-11-03T22:08:44Z")

</div>

You need to read up on PM2 commands.

You can restart node-red with something like `pm2 restart Node-RED --update-env; pm2 logs` (that will also show the logs in the terminal. Your pm2 session name might be different from `Node-RED` as I've called mine.

You can also do `pm2 kill` which kills pm2 completely.

I have all these things set up as npm scripts in my package.json file so I only need to do `npm restart` which runs `pm2 restart Node-RED --update-env && pm2 logs`.

I have a pm2 config file so `npm start` runs `pm2 start ecosystem.config.js && pm2 logs`.

---

<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:** [3 November 2024 22:23 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/3 "2024-11-03T22:23:33Z")

</div>

thanks for answer, npm restart doesn't work for me (done on node red flder where is package.json file, maybe I've to do it on pm2 folder?

```auto
C:\Users\Admin\.node-red>npm restart

> node-red-project@0.0.1 restart
> npm stop --if-present && npm start

npm error Missing script: "start"
npm error
npm error Did you mean one of these?
npm error npm star # Mark your favorite packages
npm error npm stars # View packages marked as favorites
npm error
npm error To see a list of scripts, run:
npm error npm run
npm error A complete log of this run can be found in: C:\Users\Admin\AppData\Local\npm-cache\_logs\2024-11-03T22_14_35_105Z-debug-0.log

```

pm2 kill works, then I have to start it again with pm2 start, but NR will start only with pm2 start C:\Users\<USER-NAME\>\AppData\Roaming\npm\node\_modules\node-red\red.js

pm2 restart doesn't exist, as well `pm2 restart Node-RED --update-env && pm2 logs` returns an error, I've probably to restart red.js

my best solution is to restart pm2, do you know how to? Thanks

---

<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:** [3 November 2024 22:45 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/4 "2024-11-03T22:45:38Z")

</div>

You need to configure your package.json correctly.

Here is what I have:

```auto
D:\src\nr>npm run
Lifecycle scripts included in node-red-master@2.0.3:
  start
    pm2 start ecosystem.config.js && pm2 logs
  restart
    pm2 restart Node-RED --update-env && pm2 logs

```

An extract of my ecosystem config file:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/9852dea8b6dd1a29801cf4964cac8b5c1b69ad8a.png)

Note that I'm using my alternate installer so Node-RED is installed locally not globally and the userDir home folder is in the `data` sub-folder under the node-red folder.

---

<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:** [4 November 2024 08:55 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/5 "2024-11-04T08:55:58Z")

</div>

thanks for help, honestly.. I don't feel to pay attention much about this, all is working, I have lot of work and can't spend time learning something I don't know, read documentations and so on.  
I know how to stop and how to start pm2 back, but I would like to know if there is a quick way to restart it. If not, I'll make a batch file 🙂

---

<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:** [4 November 2024 09:25 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/6 "2024-11-04T09:25:19Z")

</div>

Yes, as already mentioned. Since I keep the terminal window open where I start Node-RED, restart is as simple as ctrl-c to exit the log then `npm restart`. Even simpler if I've changed a watched file since PM2 does it all for me.

---

<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:** [4 November 2024 10:04 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/7 "2024-11-04T10:04:33Z")

</div>

I haven't any window with NR, it is executed automatically in background from pm2 during boot.  
Npm restart doesn't works for me, as I posted above

---

<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:** [2 February 2025 10:04 UTC](https://discourse.nodered.org/t/how-stop-node-red-under-windows-when-started-from-pm2/92888/8 "2025-02-02T10:04:44Z")

</div>

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