# Node red automatic reboot if that suddenly shutdown

**URL:** <https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229>\
**Category:** General\
**Created:** [7 March 2021 22:32 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229 "2021-03-07T22:32:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mac5562](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mac5562/32/34943_2.png) [@mac5562](https://discourse.nodered.org/u/mac5562)\
**Post date:** [7 March 2021 22:32 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/1 "2021-03-07T22:32:37Z")

</div>

Hi !

Someone know, is it possible to set a automatic restart if node red suddenly shutting down?  
It would be good because, sometimes node red gone away, and i'm not always there to re launch the hole node red.

Thank you for your answer

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 March 2021 22:35 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/2 "2021-03-07T22:35:29Z")

</div>

I think a _watchdog_ is what you want, but that is more the O/S than Node-Red.

(I'm not an expert in that sense of the word)

---

<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:** [7 March 2021 23:32 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/3 "2021-03-07T23:32:59Z")

</div>

I rarely have node-red crash. It might be worth checking your logs, see what is crashing node-red. Usually it is a contrib node.

As for auto restart, are you running node-red as a service? There are options you can set to auto restart the service (no real need to reboot the device)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 March 2021 07:17 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/4 "2021-03-08T07:17:57Z")

</div>

What OS are you using?

---

<div class="post-metadata">

**Author:** ![mac5562](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mac5562/32/34943_2.png) [@mac5562](https://discourse.nodered.org/u/mac5562)\
**Post date:** [8 March 2021 12:58 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/5 "2021-03-08T12:58:19Z")

</div>

Actually, the node which cause that is not a contrib node

No i'm not running as service yet

---

<div class="post-metadata">

**Author:** ![mac5562](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mac5562/32/34943_2.png) [@mac5562](https://discourse.nodered.org/u/mac5562)\
**Post date:** [8 March 2021 12:59 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/6 "2021-03-08T12:59:25Z")

</div>

Win 10, but in this week probably i switch to raspbarry

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 March 2021 15:48 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/7 "2021-03-08T15:48:33Z")

</div>

> [@mac5562](#):
>
> probably i switch to raspbarry

When you do that, install node-red using the [recommended script](https://nodered.org/docs/getting-started/raspberrypi) and it will install a systemd service file. To enable that run  
`sudo systemctl enable nodered`  
and then it will automatically run on boot, and will automatically restart if node-red crashes.

---

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [8 March 2021 15:51 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/8 "2021-03-08T15:51:17Z")

</div>

pm2 is another option you can check, works on linux/windows/Mac and can launch and watchdog your process.

---

<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:** [8 March 2021 19:14 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/9 "2021-03-08T19:14:32Z")

</div>

> [@mac5562](#):
>
> Actually, the node which cause that is not a contrib node

So what is causing your crash? A built in node? node-red runtime? Perhaps you could post logs from your crash & we can help you fix it?

If it is node-red or a built in node, it would be good if you could feedback on the forum or as an issue (for the devs to address it) -surely that is a better outcome than restarting/rebooting?

---

<div class="post-metadata">

**Author:** ![mac5562](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mac5562/32/34943_2.png) [@mac5562](https://discourse.nodered.org/u/mac5562)\
**Post date:** [8 March 2021 21:06 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/10 "2021-03-08T21:06:54Z")

</div>

I already wrote about that here:

> [@Uncaught exception from mysql nodes](https://discourse.nodered.org/t/uncaught-exception-from-mysql-nodes/41732):
>
> Hi ! Is there anyone, who has some experience with the mysql node? My problem the whole node-red randomly shutting down thanks to a uncaught exception, which caused by the mysql node. Here it is a screenshoot, about what exactly happend. Someone know how the fix that ? Because it's very anoing problem, and thanks for that the whole system is unstable.

And i opened a issue thread on node red's github page.

> <https://github.com/node-red/node-red-nodes/issues/763>
>
> Hi !
> 
> Randomly i got a unhandled exception form mysql node. Here is what i got… from console:
> 
> 27 Feb 16:31:45 - \[red\] Uncaught Exception: 
> 27 Feb 16:31:45 - Error: Connection lost: The server closed the connection. 
> at Protocol.end (C:\\Users\\tamas\\.node-red\\node modules\\mysql\\lib\\protocol\\Protocol.js:112:13) 
> at Socket.tanonymoust (C:\\Users\\tamas\\.node-red\\node modules\\mysql\\lib\\Connection.js:94:20 
> at Socket.\<anonymous\> (C:\\Users\\tamas\\.node-red\\node modules\\mysql\\lib\\Connection.js:526:10) 
> at Socket.emit (events.js:326:22) 
> at endReadableNT (\_stream\_readable.js:1223:12) 
> at processTicksAndRejections (internal/process/task queues.js:84:21) 
> 
> Can you help me?
> 
> \- \[\] Node-RED version: 1.2.7
> \- \[\] node.js version: v12.19.0
> \- \[\] npm version: 6.14.8
> \- \[\] Platform/OS: Windows\_NT 10.0.19042 x64 LE
> \- \[\] Browser: chrome 88.0.4324.190 64 bit

---

<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:** [7 May 2021 21:07 UTC](https://discourse.nodered.org/t/node-red-automatic-reboot-if-that-suddenly-shutdown/42229/11 "2021-05-07T21:07:09Z")

</div>

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