# Dynamically Disable individual nodes

**URL:** <https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396>\
**Category:** Feature Requests\
**Created:** [15 October 2024 06:26 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396 "2024-10-15T06:26:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [15 October 2024 06:26 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/1 "2024-10-15T06:26:04Z")

</div>

From time to time there comes a need to disable individual nodes.  
At the moment I'm storing those nodes into separate flow and disable it which looks odd (but it works)

Is there any plans to implement this functionality or is it not possible because of some restrictions?

My use case is to simulate TCP/IP nodes connection drop  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/6/566e7b9a5367f7a5431a560781dc64688a750b0c.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/080d21318d390d18951676fddb3ce4820798d3c3.png)

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 October 2024 06:49 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/2 "2024-10-15T06:49:07Z")

</div>

This has already been possible for a long time. 🙂

You can easily disable/enable selected nodes via the context menu. Right click on a node, then "Node" --\> "Disable selected nodes".

Tip: I'm using that feature regularly, so I added custom keyboard shortcuts (`crtl-shift-d` and `crtl-shift-e`) for that.

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [15 October 2024 06:51 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/3 "2024-10-15T06:51:22Z")

</div>

Thanks, that is clear. I changed topic name, my request is to be able to do it dynamically.

Same as described in here:

> [@How do I dynamically enable or disable config nodes?](https://discourse.nodered.org/t/how-do-i-dynamically-enable-or-disable-config-nodes/63648/4):
>
> It may not be posible for me to dynamiclly enable/disable nodes

Changed topic name

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 October 2024 06:59 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/4 "2024-10-15T06:59:14Z")

</div>

Ah, you mean disabling them via message.

The "disable" flag is stored in the flow, it's no a runtime feature. So I don't think it is currently possible without modifying and redeploying, either using the editor or the admin endpoints.

That would be something for the core devs to consider.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [15 October 2024 07:41 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/5 "2024-10-15T07:41:24Z")

</div>

If you want your connection to end in nirvana (i.e. get no response) why not use a switch node that x% of the time hits a disabled node?

Something like this flow:

```auto
[{"id":"800d74d9379d0299","type":"inject","z":"19b2bc07fbb4a423","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":522,"y":581,"wires":[["5dd0c0a13bc3c674"]]},{"id":"5dd0c0a13bc3c674","type":"switch","z":"19b2bc07fbb4a423","name":"","property":"$random()","propertyType":"jsonata","rules":[{"t":"gt","v":"0.5","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":717,"y":602,"wires":[["86ef039c237c1e66"],["f92464f9cfbb3c8f"]]},{"id":"86ef039c237c1e66","type":"debug","z":"19b2bc07fbb4a423","name":"debug 306","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":909,"y":528,"wires":[]},{"id":"f92464f9cfbb3c8f","type":"debug","z":"19b2bc07fbb4a423","d":true,"name":"debug 307","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":919,"y":642,"wires":[]}]

```

 ![Screenshot 2024-10-15 at 09.39.46](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b296387fc65d57f6d4abf8e3f661a585a1d043c7.png)

You could also add a global variable to that switch so that you toggle it or add to toggle to a dashboard to switch or a number of other things to make this dynamic (i.e. without having to do a redeploy).

---

<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:** [15 October 2024 07:50 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/6 "2024-10-15T07:50:43Z")

</div>

Do you specifically mean config nodes?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 October 2024 08:08 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/7 "2024-10-15T08:08:25Z")

</div>

In what regard?

You can disable any node in the editor, even config nodes. Sometimes I use that "feature" to manually reset a config node during the development of custom nodes (e.g. to force reestablishing connections).

However, the custom keyboard shortcuts I set up only work for nodes on the canvas.

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [15 October 2024 08:14 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/8 "2024-10-15T08:14:33Z")

</div>

If you just temporarily want to **stop** the flow of message you could use contrib simple gate node.

> **[node-red-contrib-simple-gate](https://flows.nodered.org/node/node-red-contrib-simple-gate)**
>
> A gate node for node-RED

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [15 October 2024 08:17 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/9 "2024-10-15T08:17:58Z")

</div>

~~You can do this by editing the node properties and then deploying the flow(s).~~  
Works only from the editor

---

<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:** [15 October 2024 08:21 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/10 "2024-10-15T08:21:09Z")

</div>

> [@kuema](#):
>
> In what regard?

The solutions suggested, using a Switch node or similar to stop messages flowing do not work for config nodes. As far as I know there is no way to disable a config node dynamically.

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [15 October 2024 08:21 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/11 "2024-10-15T08:21:29Z")

</div>

I don't want to stop a flow of messages.

In reality NR is communicating with PLC via TCP request.  
I want to create test scenarios, which simulate TCP connection drop when PLC TCP side is misconfigured and drops connection.

Best representation of that I found is to create a temp listener like TCP-out node. Then connection is established  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/6/566e7b9a5367f7a5431a560781dc64688a750b0c.png)  
tcp request node change status - I pick it up and do following actions

when I disable tcp-out node, tcp-request node changes status once again  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/080d21318d390d18951676fddb3ce4820798d3c3.png)

I pick this status and do further actions.

> [@GogoVega](#):
>
> Works only from the editor

since you are one of core devs I wanted to ask if it is fundamentally possible to do it and can it be implemented further nodered versions (NR v5 etc), or is it just not possible and only work around is to disable whole flow?

This request is popping up every year or so

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [15 October 2024 08:24 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/12 "2024-10-15T08:24:05Z")

</div>

> [@KarolisL](#):
>
> when I disable tcp-out node, tcp-request node changes status once again I pick this status and do further actions

have you tried setting up a switch node? And why does it not work with a switch node?

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [15 October 2024 08:25 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/13 "2024-10-15T08:25:15Z")

</div>

It's the connection he wants to cut, not the message. As long as the node is active, the connection is also active.

> [@KarolisL](#):
>
> since you are one of core devs

I am a contributor but I am not part of the team 😅

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [15 October 2024 08:27 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/14 "2024-10-15T08:27:54Z")

</div>

> [@GogoVega](#):
>
> It's the connection he wants to cut, not the message. As long as the node is active, the connection is also active.

Exactly! I've noticed that trying to automate testing is quite a separate challenge (but that's a separate topic)

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [15 October 2024 08:28 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/15 "2024-10-15T08:28:02Z")

</div>

So literally deactivating the node via disabling it and then redeploying the flow is the _only_ way to achieve that? - Not being cynical here, literally surprised to think that!

EDIT: weird really, I was thinking this morning that I would like to have a HTTP response node that just drops the connection without sending out a reply - I couldn't think of a way to do that but it wasn't important either 😉

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [15 October 2024 08:31 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/16 "2024-10-15T08:31:40Z")

</div>

Either you create a custom node that does it by itself with a timeout (or button in editor).

Yes, I don't see any other possibility.

---

<div class="post-metadata">

**Author:** ![KarolisL](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@KarolisL](https://discourse.nodered.org/u/KarolisL)\
**Post date:** [15 October 2024 08:32 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/17 "2024-10-15T08:32:25Z")

</div>

Still you know core better than 99% of users. Maybe somebody from the core will provide insights.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [15 October 2024 08:39 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/18 "2024-10-15T08:39:22Z")

</div>

What about a function node? The connection - at least in the case of a HTTP in node - is transported with the message, so it would be possible, in a function node, to close that connection.

The HTTP out node uses the [`msg.res._res`](https://github.com/node-red/node-red/blob/2854351909dee9f92597faba3f37239134294eec/packages/node_modules/%40node-red/nodes/core/network/21-httpin.js#L356) to close the original connection made when the client connects to the http in node.

So if I created a function node that does this `msg.res._res.socket.destroy()` I might be able to drop the line.

---

<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:** [15 October 2024 08:40 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/19 "2024-10-15T08:40:44Z")

</div>

> [@KarolisL](#):
>
> At the moment I'm storing those nodes into separate flow and disable it which looks odd (but it works)

Don't forget that you can use the library feature of the export/import dialog for this.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [15 October 2024 08:40 UTC](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396/20 "2024-10-15T08:40:47Z")

</div>

To really drop/close the connection, I see only two options:

- disable the config node
  - only manually at this time (edit/deploy)

- add support for control messages to the TCP core nodes (like mqtt and some other nodes have implemented it)

[Next page](https://discourse.nodered.org/t/dynamically-disable-individual-nodes/92396.md?page=2)
