Unable to restart Node Red from a node

I have spent all day trying to setup a way to restart Node Red from itself. I tried the Exec node many different ways, but the commands like "node-red-restart" give a 127 command not found error. I also tried with the API method, but I get this JSON error. I have read the documentation and various forum threads. What could I be missing?

Welcome to the forum @flyoffacliff

Are you running Node-red on Linux?
How did you install it?
Are you using docker?

Error 127 suggests that you are missing /usr/bin/node-red-restart or the systemd script for Node-red, or if it's docker, you can't see these.

On my Raspberry Pi I can restart using an exec node to run either sudo systemctl restart nodered or /usr/bin/node-red-restart (which just calls sudo systemctl restart nodered)

If I had followed the advice on securing my new NR install these commands would fail because they use sudo but I don't think that's the cause of your problem.

I am using the Node Red addon for Home Assistant. Yes it's Linux.

Ah Home Assistant. I'm not familiar with that.

I suppose you could try an exec node with the 'nuclear option' sudo reboot.

Then it is running node-red under docker. You could try and automate a restart using the docker restart command but I don't know how that would affect any supervisory that home assistant does for its "addon". Probably worth asking on home assistant forum if there is some automatable way of restarting the node-red addon.

Home Assistant has a service call for this (now referred to as action). You can test it in HA's Developer Tools page and then convert the data component to JSON ({ "addon": "a0d7b954_nodered" }) so you could run it from Node Red using the action node (from the HA palette nodes):

action: hassio.addon_restart
data:
  addon: a0d7b954_nodered

That's what I am currently doing, but it's not ideal because it restarts the entire Docker container containing the Node-Red addon, which is over-kill for me. I am just trying to restart the flows. Same as what clicking the Deploy button does.

Ah the confusion is you said you wanted to restart Node Red. You could look into the Node Red Admin API - you can POST to /flows to do a deployment, although I've never used it.

Oh, sorry. Thanks, but I spent several hours playing with the admin API and it just did not work. Node Red throws an internal stack trace into the Console no matter what commands I send.

My next step would be to try it on a fresh install and post here exactly what I'm doing with the API, but I don't know if I'll get to it. It's a pretty low priority for me.

That should certainly never happen. Please post a sample flow showing the problem if possible.