# Node red starts but not as a service

**URL:** <https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971>\
**Category:** General\
**Created:** [6 January 2020 15:59 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971 "2020-01-06T15:59:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiagonmas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tiagonmas/32/15850_2.png) [@tiagonmas](https://discourse.nodered.org/u/tiagonmas)\
**Post date:** [6 January 2020 15:59 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/1 "2020-01-06T15:59:34Z")

</div>

Hi,  
I can start node red normally, but while installing it as a service it does not start, providing an error

Starting as a service, it does not work:

```auto
pi@raspberrypi:~/shared/mqtt-topic-logger/tlogs/tele/tasmota $ sudo systemctl start node-red
pi@raspberrypi:~/shared/mqtt-topic-logger/tlogs/tele/tasmota $ sudo systemctl status node-red
● node-red.service - Node-RED
   Loaded: loaded (/etc/systemd/system/node-red.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-01-06 15:56:38 GMT; 2min 3s ago
  Process: 2377 ExecStart=/usr/bin/node-red-pi --max-old-space-size=128 -v (code=exited, status=1/FAILURE)
 Main PID: 2377 (code=exited, status=1/FAILURE)

Jan 06 15:56:38 raspberrypi node-red[2377]: at Object.<anonymous> (/usr/lib/node_modules/node-red/red.js:98:50)
Jan 06 15:56:38 raspberrypi node-red[2377]: at Module._compile (internal/modules/cjs/loader.js:778:30)
Jan 06 15:56:38 raspberrypi node-red[2377]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Jan 06 15:56:38 raspberrypi node-red[2377]: at Module.load (internal/modules/cjs/loader.js:653:32)
Jan 06 15:56:38 raspberrypi node-red[2377]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
Jan 06 15:56:38 raspberrypi node-red[2377]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Jan 06 15:56:38 raspberrypi node-red[2377]: at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
Jan 06 15:56:38 raspberrypi node-red[2377]: at startup (internal/bootstrap/node.js:283:19)
Jan 06 15:56:38 raspberrypi systemd[1]: node-red.service: Main process exited, code=exited, status=1/FAILURE
Jan 06 15:56:38 raspberrypi systemd[1]: node-red.service: Failed with result 'exit-code'.

```

Starting normally, it works

```auto
pi@raspberrypi:~ $ node-red-pi --max-old-space-size=256
6 Jan 15:38:57 - [info]

Welcome to Node-RED
===================

6 Jan 15:38:57 - [info] Node-RED version: v1.0.3
6 Jan 15:38:57 - [info] Node.js version: v10.18.0
6 Jan 15:38:57 - [info] Linux 4.19.75+ arm LE
6 Jan 15:39:12 - [info] Loading palette nodes
6 Jan 15:39:51 - [info] Settings file : /home/pi/.node-red/settings.js
6 Jan 15:39:51 - [info] Context store : 'default' [module=memory]
6 Jan 15:39:51 - [info] User directory : /home/pi/.node-red
6 Jan 15:39:51 - [warn] Projects disabled : editorTheme.projects.enabled=false
6 Jan 15:39:51 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
6 Jan 15:39:51 - [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.
---------------------------------------------------------------------

6 Jan 15:39:51 - [info] Starting flows
6 Jan 15:39:55 - [info] Started flows
6 Jan 15:39:55 - [info] Server now running at http://127.0.0.1:1880/
6 Jan 15:39:55 - [info] [mqtt-broker:localhost] Connected to broker: mqtt://localhost:1883
^C6 Jan 15:50:12 - [info] Stopping flows
6 Jan 15:50:13 - [info] [mqtt-broker:localhost] Disconnected from broker: mqtt://localhost:1883
6 Jan 15:50:13 - [info] Stopped flows

```

Working on a Raspberry Pi Model B Revision 2.0 - 512MB, with Raspbian Buster Lite.

```auto
pi@raspberrypi:~ $ node --version
v10.18.0
pi@raspberrypi:~ $ npm --version
6.13.4

```

node red was installed using

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

```

---

<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:** [6 January 2020 16:19 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/2 "2020-01-06T16:19:59Z")

</div>

I don't know where node-red.service came from, perhaps it came with the default raspbian install, but the one installed by the recommended script is nodered.service, so try  
`sudo systemctl start nodered`

---

<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:** [6 January 2020 16:22 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/3 "2020-01-06T16:22:57Z")

</div>

The error log from the system start version is limited to just a few lines and doesn't show what is actually causing the issue I don't think.

You will need to list more of the log. Something like `sudo journalctl -u node-red -n 50` should do it I think.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 January 2020 16:23 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/4 "2020-01-06T16:23:28Z")

</div>

> [@tiagonmas](#):
>
> /mqtt-topic-logger/tlogs/tele/tasmota $ sudo systemctl start node-red

The docs on the Pi page say to use it as a service to do

```auto
sudo systemctl enable nodered.service

```

---

<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:** [6 January 2020 16:24 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/5 "2020-01-06T16:24:32Z")

</div>

> [@cymplecy](#):
>
> sudo systemctl enable nodered.service

Just to note that that command enables starting on boot, it does not actually start the service.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 January 2020 16:25 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/6 "2020-01-06T16:25:38Z")

</div>

Yes and they also say to use

node-red-start

to manually start 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:** [6 January 2020 16:28 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/7 "2020-01-06T16:28:51Z")

</div>

> [@cymplecy](#):
>
> node-red-start

That is a good way of starting it as it starts the service and then shows the log, it is equivalent to something like

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

```

The fundamental problem that @tiagonmas has is probably that he is using the wrong service name, as I noted earlier.

---

<div class="post-metadata">

**Author:** ![tiagonmas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tiagonmas/32/15850_2.png) [@tiagonmas](https://discourse.nodered.org/u/tiagonmas)\
**Post date:** [6 January 2020 17:10 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/8 "2020-01-06T17:10:36Z")

</div>

Thanks! that was it.  
I created the service definition based on a post on stackoverflow.  
using the service you mention did the trick. 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:** [6 January 2020 17:11 UTC](https://discourse.nodered.org/t/node-red-starts-but-not-as-a-service/19971/9 "2020-01-06T17:11:41Z")

</div>

Don't forget to remove the one you created or you may get confused again in the future. 🙂
