# Restarting node-red service in Bookworm OS

**URL:** <https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720>\
**Category:** General\
**Created:** [18 August 2025 14:16 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720 "2025-08-18T14:16:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manikandan](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Manikandan](https://discourse.nodered.org/u/Manikandan)\
**Post date:** [18 August 2025 14:16 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/1 "2025-08-18T14:16:53Z")

</div>

Hello Everyone,

I recently upgraded my Revolution Pi from **Stretch** to **Bookworm OS**. In my Node-RED application, I used to restart the Node-RED service once a week using the `sudo node-red-restart` command in an Exec node.

With the latest release, it appears that running `sudo` from within Node-RED is no longer supported due to the new sandboxing and privilege restrictions.

I am looking for **recommended methods or best practices** to achieve the following:

1. **Restart Node-RED** at a scheduled time or based on certain application variables.

2. **Reboot the entire hardware** once a week.

Ideally, the solution should allow some **dynamic control from Node-RED** (e.g., conditional restart based on variable values) while complying with the **Bookworm OS restrictions**.

Any guidance, examples, or suggested approaches would be highly appreciated.

Thank you in advance!

Best Regards,

Mani

---

<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:** [18 August 2025 14:40 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/2 "2025-08-18T14:40:03Z")

</div>

It isn't that bookworm has added restrictions, it is that older pi OS disabled them.  
In a terminal run  
`sudo visudo`  
then add to the end

`myusername ALL=(ALL) NOPASSWD: /usr/bin/node-red-restart`  
where `myusername` is the name of the user that runs node-red and `/usr/bin/node-red-restart` is the full path to the command. Run  
`which node-red-restart`  
to check that is correct for your setup.

That allows the node-red user to run `sudo node-red-restart` without entering a password, so you can call it in an exec node.

---

<div class="post-metadata">

**Author:** ![Manikandan](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Manikandan](https://discourse.nodered.org/u/Manikandan)\
**Post date:** [18 August 2025 17:52 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/3 "2025-08-18T17:52:12Z")

</div>

> [@Colin](#):
>
> sudo node-red-restart

Hello Colin,

Thanks for your prompt response.

As mentioned , i have tired your suggestion. Got the below response.

```shell
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

```

**Also, please refer the below comments mentioned in the Bookworm OS release.**

```bash
The Node-RED process runs as the system user nodered. All settings and user data are located in the
folder /var/lib/revpi-nodered. This path is also the only path where the user can write data.
The rest of the file system is only available for reading.

```

Please do suggest.

Best Regards,

_Mani_

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 August 2025 18:05 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/4 "2025-08-18T18:05:41Z")

</div>

The message

```auto
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

```

is a consequence of this line in your /etc/systemd/system/multi-user.target.wants/nodered.service file:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/ac5101e28ff0c5f257471d7773c97a0ea15730e2.png)

Change true to false (you will have to edit the file using sudo in a terminal) and reboot.

Note that if, as you suggest, this is a new security feature in Node-red (I've never come across it before), there may be better options than merely turning it off.

---

<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:** [18 August 2025 20:15 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/5 "2025-08-18T20:15:07Z")

</div>

Do you know where that line has come from? It is not in our standard pi install script as far as I can see.

---

<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:** [18 August 2025 20:21 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/6 "2025-08-18T20:21:02Z")

</div>

> [@Manikandan](#):
>
> Also, please refer the below comments mentioned in the Bookworm OS release.

Are you running the node-red install provided with bookworm or installing it yourself? Certainly this is not a problem running the recommended way of installing node-red on a normal pi. I don't know whether that works on a revpi though.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 August 2025 20:30 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/7 "2025-08-18T20:30:34Z")

</div>

I don't know, sorry.

---

<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:** [18 August 2025 20:43 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/8 "2025-08-18T20:43:17Z")

</div>

Is that in your service file or do you somehow know that @Manikandan has it in his?

Are you running on a revpi too?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 August 2025 21:03 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/9 "2025-08-18T21:03:05Z")

</div>

> [@Colin](#):
>
> do you somehow know that @Manikandan has it in his?

Nope.

I duckduckgoed it Colin & found mentions of it in a systemd script for a different application.  
Adding the line to my Node-red script on a Pi Zero 2 with Bookworm caused the same message when I ran an exec command with sudo.

As I said, I've never come across it before.

I have no idea where it comes from and I don't see it in the current Pi install script (though it has possibly been added to the model systemd script file).  
Even if it was in the install I would not see it because all my Pies already have modified systemd scripts, which do not get overwritten.

I have often pushed for better security of Node-red, I somehow doubt if this is what @Manikandan has stumbled upon.

---

<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:** [18 August 2025 21:14 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/10 "2025-08-18T21:14:05Z")

</div>

I suspect that he is running a revpi supplied version of node red. The docs he pointed out are revpi specific. So the title of the thread is misleading, as, if I am right, then this is a revpi issue, not a node-red one.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 August 2025 21:23 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/11 "2025-08-18T21:23:31Z")

</div>

For sure it's not a standard Bookworm installation. The bit about where the user can write data seems 'eccentric', ie bonkers.

> [@Manikandan](#):
>
> ```auto
> All settings and user data are located in the
> folder /var/lib/revpi-nodered. This path is also the only path where the user can write data.
> The rest of the file system is only available for reading.
> 
> ```

---

<div class="post-metadata">

**Author:** ![Manikandan](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Manikandan](https://discourse.nodered.org/u/Manikandan)\
**Post date:** [19 August 2025 07:56 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/12 "2025-08-19T07:56:30Z")

</div>

Hello @Colin and @jbudd ,

Apologies for the misleading title. Yes it a RevPi Image (Bookworm) from Revolution Pi .

And also it’s revpi-nodered.

Already i have reached-out to revolution pi team to provide some way-out for this requirement to maintain my existing process flow and code structure.

Regards,

_Mani_

---

<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:** [19 August 2025 08:12 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/13 "2025-08-19T08:12:18Z")

</div>

Look in /usr/lib/systemd/system for the node red service file. Possibly it will be nodered.service or node-red.service and look in there for the line @jbudd suggested. If it is there change it to false and reboot.

---

<div class="post-metadata">

**Author:** ![Manikandan](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Manikandan](https://discourse.nodered.org/u/Manikandan)\
**Post date:** [19 August 2025 08:56 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/14 "2025-08-19T08:56:22Z")

</div>

Hi @Colin ,

Thanks for your prompt response,

Please refer the original content of the service under /usr/lib/systemd/system/noderedrevpinodes-server.service below.

```auto
[Unit]
Description=Revolution Pi NodeRed Service
After=network.target
Documentation=https://gitlab.com/revolutionpi/noderedrevpinodes-server

[Service]
Type=simple
ExecStart=/usr/bin/sh -c 'exec /usr/bin/noderedrevpinodes-server 2>> /var/log/revpi-server.log'
WorkingDirectory=/usr/share/noderedrevpinodes-server/
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target

```

Tried adding the ‘NoNewPrivileges=false‘ under service. rebooted the hardware , still the same issue.

Best Reagrds,

_Mani_

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 August 2025 09:43 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/15 "2025-08-19T09:43:28Z")

</div>

> [@Manikandan](#):
>
> /usr/lib/systemd/system/noderedrevpinodes-server.service ...  
> Tried adding the ‘NoNewPrivileges=false‘ under service. rebooted the hardware , still the same issue.

That service seems to be some python utilities to allow Node-red to access the GPIO pins and it's not surprising that changing it has no effect on Node-red itself.

There are very good reasons in an industrial setting to prevent Node-red from using sudo.

Can you restart Node-red via a root cron job?

---

<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:** [19 August 2025 20:01 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/16 "2025-08-19T20:01:21Z")

</div>

> [@Manikandan](#):
>
> `Documentation=https://gitlab.com/revolutionpi/noderedrevpinodes-server`

Looking at that then as @jbudd says, that is not node-red itself but is a helper service. There must be another service for node red itself.

I tend to think though, that if you want to restart it regularly, then, again as @jbudd hints, a cron task may well be the way to go.

---

<div class="post-metadata">

**Author:** ![DiverRich](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/diverrich/32/64523_2.png) [@DiverRich](https://discourse.nodered.org/u/DiverRich)\
**Post date:** [19 August 2025 23:03 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/17 "2025-08-19T23:03:44Z")

</div>

I may be misunderstanding exactly what you’re asking, but i just use a flow with an exec node to do restarts at specific intervals or manually from the node-red editor. I also use a few tricks with global state variables, inject nodes and virtual switches to survive random restarts and what-not to keep things on track. Happy to provide more details if you’d like.

 ![Screenshot 2025-08-19 at 4.00.32 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/4/6413ca7c45d15084861ab0b3a8c7bc6293f3e401.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 August 2025 23:09 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/18 "2025-08-19T23:09:37Z")

</div>

/usr/bin/node-red-restart is a shell script which calls sudo systemctl restart nodered.

If the Node-red user is prohibited from using sudo it will fail, though maybe the NoNewPrivileges line in a systemd script, which @Manikandan has not confirmed he has, will not prevent sudo in a script.  
In which case, what use is it? 🤔

---

<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:** [20 August 2025 08:00 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/19 "2025-08-20T08:00:36Z")

</div>

> [@jbudd](#):
>
> /usr/bin/node-red-restart is a shell script which calls sudo systemctl restart nodered.

That is true if node-red were installed using the Pi install script, but this is not the case here. It is the revpi node red install that is being used. We don't know what is in the command in this case, it could be the command you suggest, but not necessarily.

@Manikandan run  
`which node-red-restart`  
which will tell you where that file is, possibly something like /usr/bin/node-red-restart. Then look at what is in that using  
`cat /usr/bin/node-red-restart`  
but using the correct file of course. That will tell you what it is doing.

> [@jbudd](#):
>
> If the Node-red user is prohibited from using sudo it will fail,

I think the error would be different if that were the case.

> [@jbudd](#):
>
> If the Node-red user is prohibited from using sudo it will fail, though maybe the NoNewPrivileges line in a systemd script, which @Manikandan has not confirmed he has, will not prevent sudo in a script.  
> In which case, what use is it?

Sorry, I don't understand what you are saying here.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [20 August 2025 08:10 UTC](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720/20 "2025-08-20T08:10:05Z")

</div>

> [@Colin](#):
>
> Sorry, I don't understand what you are saying here.

The misunderstanding is mutual.

[Next page](https://discourse.nodered.org/t/restarting-node-red-service-in-bookworm-os/98720.md?page=2)
