# "sudo systemctl enable nodered.service" in ubuntu fail?

**URL:** <https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556>\
**Category:** General\
**Created:** [10 October 2019 14:09 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556 "2019-10-10T14:09:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [10 October 2019 14:09 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/1 "2019-10-10T14:09:34Z")

</div>

Hello all , follow the instruction by "[https://nodered.org/docs/getting-started/raspberrypi](https://nodered.org/docs/getting-started/raspberrypi)".  
I have run:

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodere

```

```auto
sudo systemctl enable nodered.service

```

but failed .  
The log :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/19f0b01bf38016f126cd8cf8c3ac01ee5b352be7.png)

ubuntu 16.04  
npm 6.9.0  
node-red v10.16.3

I have searched for some similar issue in forum,but still can not find a solution.  
Is there any suggestion ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [10 October 2019 14:11 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/2 "2019-10-10T14:11:09Z")

</div>

As the error says, you should check the permissions on the file `/home/gaofei/.node-red/settings.js`.

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [10 October 2019 14:13 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/3 "2019-10-10T14:13:36Z")

</div>

Thanks, the setting.js is a default configuration.  
Do I have to change it ?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [10 October 2019 14:16 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/4 "2019-10-10T14:16:16Z")

</div>

> [@gaofei207](#):
>
> Do I have to change it ?

Normally it all just works. But in this instance _something_ has gone wrong with the permissions and it is preventing Node-RED from reading your settings file.

Had you run node-red manually before starting it as a service?

Can you share the output of the command:

```auto
ls -la /home/gaofei/.node-red/settings.js

```

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [10 October 2019 14:21 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/5 "2019-10-10T14:21:33Z")

</div>

Yes I can run it successfully with command " node-red" .

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/329f15fc49d5ddb7f8265c3325706969a969dc26.png)

by the way ,I have check the /lib/systemd/system/ nodered.service and confirm that the user is "gaofei" .  
Thanks for your reply.

---

<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 October 2019 16:48 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/6 "2019-10-10T16:48:20Z")

</div>

That is odd. You say you have run systemctl enable, but did you restart node-red (enable just tells it to run on boot). In a terminal run

```auto
node-red-stop
node-red-start

```

and post the full log.  
If still getting the error also post nodered.service

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [11 October 2019 00:48 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/7 "2019-10-11T00:48:23Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4cbd30206e749759aaefbc18065e75661366e8a8.png)

If close the window ,the service do not keep running in the background.

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

I find a similar topic in [Unhandled rejection Error: EACCES: permission denied,](https://discourse.nodered.org/t/unhandled-rejection-error-eacces-permission-denied/9559/11).

```auto
sudo apt-get purge nodejs

```

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

```

also no effect.

Thanks.

---

<div class="post-metadata">

**Author:** ![miker256](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/miker256/32/13042_2.png) [@miker256](https://discourse.nodered.org/u/miker256)\
**Post date:** [11 October 2019 03:50 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/8 "2019-10-11T03:50:09Z")

</div>

hi @gaofei207, there's a snap version you could try out. 🙂

> **[Install Node-RED for Linux using the Snap Store | Snapcraft](https://snapcraft.io/node-red)**
>
> Get the latest version of Node-RED for Linux - Low-code programming for event-driven applications

---

<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:** [11 October 2019 06:13 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/9 "2019-10-11T06:13:52Z")

</div>

I don't advise using the snap, the pi install script should do it. What does  
`sudo systemctl status nodered`  
show? Then run

```auto
sudo systemctl restart nodered
node-red-log

```

And post the result. Please copy/paste rather than screen shot, it makes it easier to access.

Edit - I have corrected the restart command above, there was a typo

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [11 October 2019 06:59 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/10 "2019-10-11T06:59:06Z")

</div>

gaofei@iZbp1fazljd8u3jfbtht09Z:~$ sudo systemctl status nodered  
[sudo] password for gaofei:  
● nodered.service - Node-RED graphical event wiring tool  
Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)  
Active: inactive (dead)  
Docs: [http://nodered.org/docs/hardware/raspberrypi.html](http://nodered.org/docs/hardware/raspberrypi.html)

Oct 10 21:03:31 iZbp1fazljd8u3jfbtht09Z systemd[1]: nodered.service: Start request repeated too quickly.  
Oct 10 21:03:31 iZbp1fazljd8u3jfbtht09Z systemd[1]: Failed to start Node-RED graphical event wiring tool.  
Oct 10 21:45:40 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 10 21:54:46 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 10 21:54:51 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 10 21:55:38 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 10 22:45:06 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 11 08:33:05 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 11 08:33:07 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
Oct 11 08:35:37 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.  
gaofei@iZbp1fazljd8u3jfbtht09Z:~ ^C gaofei@iZbp1fazljd8u3jfbtht09Z:~ sudo systemctl restart nodered  
gaofei@iZbp1fazljd8u3jfbtht09Z:~$ node-red-log

## =================== 11 Oct 14:57:58 - [info] Node-RED version: v1.0.1 11 Oct 14:57:58 - [info] Node.js version: v10.16.3 11 Oct 14:57:58 - [info] Linux 4.4.0-105-generic x64 LE 11 Oct 14:57:59 - [info] Loading palette nodes 11 Oct 14:57:59 - [warn] rpi-gpio : Raspberry Pi specific node set inactive 11 Oct 14:57:59 - [info] Settings file : /home/gaofei/.node-red/settings.js 11 Oct 14:57:59 - [info] Context store : 'default' [module=memory] 11 Oct 14:57:59 - [info] User directory : /home/gaofei/.node-red 11 Oct 14:57:59 - [warn] Projects disabled : editorTheme.projects.enabled=false 11 Oct 14:57:59 - [info] Flows file : /home/gaofei/.node-red/flows\_iZbp1fazljd8u3jfbtht09Z.json 11 Oct 14:57:59 - [info] Creating new flow file 11 Oct 14:57:59 - [warn]

## Your flow credentials file is encrypted using a system-generated key. If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials. You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

11 Oct 14:57:59 - [info] Starting flows  
11 Oct 14:57:59 - [info] Started flows  
11 Oct 14:57:59 - [info] Server now running at [http://127.0.0.1:1880/](http://127.0.0.1:1880/)

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [11 October 2019 07:04 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/11 "2019-10-11T07:04:27Z")

</div>

> [@Colin](#):
>
> sudo systemctl status nodered

It seems works . If close the window ,the service still run.  
Thanks.

---

<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:** [11 October 2019 07:49 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/12 "2019-10-11T07:49:54Z")

</div>

There is something not right as `node-red-start` should have done the same thing. Are you in the group `sudo`? Run the command `groups` to find out. If it does not show `sudo` then that is the explanation. If it does show `sudo` then what does `which node-red-start` show? If that is /usr/bin/node-red-start then could you post the contents of that here?

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [11 October 2019 08:48 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/13 "2019-10-11T08:48:14Z")

</div>

gaofei@iZbp1fazljd8u3jfbtht09Z:~ sudo groups root gaofei@iZbp1fazljd8u3jfbtht09Z:~ groups  
gaofei  
gaofei@iZbp1fazljd8u3jfbtht09Z:~$

I have add user 'gaofei' sudo permission.  
Now it works.

gaofei@iZbp1fazljd8u3jfbtht09Z:~$ sudo systemctl status nodered  
● nodered.service - Node-RED graphical event wiring tool  
Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)  
Active: active (running) since Fri 2019-10-11 16:41:42 CST; 15s ago  
Docs: [http://nodered.org/docs/hardware/raspberrypi.html](http://nodered.org/docs/hardware/raspberrypi.html)  
Main PID: 29654 (node-red)  
CGroup: /system.slice/nodered.service  
└─29654 node-red

Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: If the system-generated key is lost for any reason, your credentials  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: file will not be recoverable, you will have to delete it and re-enter  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: your credentials.  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: You should set your own key using the 'credentialSecret' option in  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: your settings file. Node-RED will then re-encrypt your credentials  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: file using your chosen key the next time you deploy a change.  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: ---------------------------------------------------------------------  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: 11 Oct 16:41:43 - [info] Starting flows  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: 11 Oct 16:41:43 - [info] Started flows  
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: 11 Oct 16:41:43 - [info] Server now running at [http://127.0.0.1:1880/](http://127.0.0.1:1880/)

Thanks for your great help.😀

---

<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:** [11 October 2019 09:45 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/14 "2019-10-11T09:45:31Z")

</div>

Check that

```auto
node-red-stop
node-red-start

```

now says it is starting it using systemd and it does not close when you break out. Then all is well.

---

<div class="post-metadata">

**Author:** ![gaofei207](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaofei207/32/13047_2.png) [@gaofei207](https://discourse.nodered.org/u/gaofei207)\
**Post date:** [11 October 2019 10:12 UTC](https://discourse.nodered.org/t/sudo-systemctl-enable-nodered-service-in-ubuntu-fail/16556/15 "2019-10-11T10:12:51Z")

</div>

It is all right now. Thanks for your kindly help.
