# Restart node-red automatically

**URL:** <https://discourse.nodered.org/t/restart-node-red-automatically/10983>\
**Category:** General\
**Created:** [10 May 2019 08:32 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983 "2019-05-10T08:32:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlosglez](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@carlosglez](https://discourse.nodered.org/u/carlosglez)\
**Post date:** [10 May 2019 08:32 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/1 "2019-05-10T08:32:13Z")

</div>

Hello,

I want that if my node-red stops for some reason that it can be restarted by itself. I was thinking in using a python script with "os.system()" and then using "crontab -e" to init it in the start of the device.

I am using a Raspberry Pi 3.

If you can attach me some code or instructions I would really appreciate it.

Thank you!

---

<div class="post-metadata">

**Author:** ![Robbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robbo/32/4491_2.png) [@Robbo](https://discourse.nodered.org/u/Robbo)\
**Post date:** [10 May 2019 08:42 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/2 "2019-05-10T08:42:53Z")

</div>

If you start node-red using the systemd method (systemctl, etc.) then you can use that to restart it on certain conditions. This would be the “correct” way to do it as well. You just need to edit the service file. I’ll let you Google on howto.

---

<div class="post-metadata">

**Author:** ![carlosglez](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@carlosglez](https://discourse.nodered.org/u/carlosglez)\
**Post date:** [10 May 2019 08:51 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/3 "2019-05-10T08:51:16Z")

</div>

So, if I use "systemctl" to init node-red if node-red fails, does it reboot by itself?

---

<div class="post-metadata">

**Author:** ![Robbo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robbo/32/4491_2.png) [@Robbo](https://discourse.nodered.org/u/Robbo)\
**Post date:** [10 May 2019 08:54 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/4 "2019-05-10T08:54:04Z")

</div>

You will need to change the node-red.service file to enable it to restart if it stops for some reason.

---

<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:** [10 May 2019 10:11 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/5 "2019-05-10T10:11:47Z")

</div>

If you installed using the recommended node red install script then the systemd script will automatically restart node-red if it crashes.

---

<div class="post-metadata">

**Author:** ![carlosglez](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@carlosglez](https://discourse.nodered.org/u/carlosglez)\
**Post date:** [10 May 2019 11:05 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/6 "2019-05-10T11:05:23Z")

</div>

So if y use the "Starting Node-RED on boot" part of the following link: "[https://nodered.org/docs/getting-started/running](https://nodered.org/docs/getting-started/running)". If node-red crashes, will it restart automatically?

---

<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:** [10 May 2019 11:13 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/7 "2019-05-10T11:13:38Z")

</div>

You should have followed these instructions for a pi.  
[https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi)  
You can run the upgrade script there to bring everything up to date. If you follow those instructions including the section on running from boot then yes, it will restart if node red crashes

---

<div class="post-metadata">

**Author:** ![carlosglez](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@carlosglez](https://discourse.nodered.org/u/carlosglez)\
**Post date:** [10 May 2019 11:15 UTC](https://discourse.nodered.org/t/restart-node-red-automatically/10983/8 "2019-05-10T11:15:50Z")

</div>

Ok. Thank you!
