# Node Red restart from within the active flow

**URL:** <https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397>\
**Category:** General\
**Created:** [12 December 2020 10:59 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397 "2020-12-12T10:59:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmoel](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@bmoel](https://discourse.nodered.org/u/bmoel)\
**Post date:** [12 December 2020 10:59 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397/1 "2020-12-12T10:59:46Z")

</div>

The problem is that the ModBus node does reconnect after the VPN disconnect and reconnect. I have set up the ModBus node to send a blank msg if the read fails. So far so good. I would then like to flow to redeploy or restart if this criteria is meet and I just can't get me head around how to use the Admin API or any other way of achieving this. I have read

> [@\[Solved\] Restarting flows programmatically](https://discourse.nodered.org/t/solved-restarting-flows-programmatically/9341):
>
> Since v0.20, the deploy menu has a new Restart Flows option. Would it be possible to provide a way to invoke this programmatically from within a flow? For example, in cases where message properties have been used to override node parameters set when a node was deployed (not encouraged, I realize, but sometimes a good idea), it could be useful to be able to recover the initial state of the flow.

And tried to understand how it works, but just cant get my head around this. Could someone share an example how to make a restart if certain criteria is meet.

Thanks in advance

---

<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:** [12 December 2020 11:46 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397/2 "2020-12-12T11:46:47Z")

</div>

If you search the forum for node red restart you will find a number of solutions. It does depend on what OS you are using, but basically the technique is to use an exec node to run a command to restart node red.

---

<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:** [12 December 2020 11:54 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397/3 "2020-12-12T11:54:49Z")

</div>

> [@bmoel](#):
>
> I would then like to flow to redeploy or restart if this criteria is meet and I just can't get me head around how to use the Admin API

There are several threads on this forum related to this. [This one](https://discourse.nodered.org/t/restart-flows-using-node-red-api/34632) uses the admin API to restart your flows via the API - import the very last flow titled "test flow:" under "Edit 2 Solution " in that link

---

<div class="post-metadata">

**Author:** ![bmoel](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@bmoel](https://discourse.nodered.org/u/bmoel)\
**Post date:** [12 December 2020 12:01 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397/4 "2020-12-12T12:01:58Z")

</div>

Thanks, guys, I will give it a try and see if I can get it figured based on the other examples.

---

<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:** [12 December 2020 12:13 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397/5 "2020-12-12T12:13:03Z")

</div>

In fact using the API is probably the preferred option as it does not need sudo privileges to do it. I must update my systems at some point to use that.

---

<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:** [10 February 2021 12:13 UTC](https://discourse.nodered.org/t/node-red-restart-from-within-the-active-flow/37397/6 "2021-02-10T12:13:09Z")

</div>

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