# Autostart Ubuntu 16.04 Problems?

**URL:** https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408
**Category:** General
**Created:** [21 April 2019 22:43 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408 "2019-04-21T22:43:23Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![longunmin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/longunmin/32/2816_2.png) [@longunmin](https://discourse.nodered.org/u/longunmin)
#### Post date: [21 April 2019 22:43 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/1 "2019-04-21T22:43:23Z")

</div>

I am trying to get Node-Red to start on boot on my NUC running Ubuntu 16.04. I am able to start using the simple `node-red` command, but any autostart option I try always fails. I have tried the recommend [autostart](https://nodered.org/docs/hardware/raspberrypi#adding-autostart-capability-using-systemd) guide, but that produces and status=1/FAILURE code. I have tried to use `node-red-log`, but it says command not found. I tried the pm2 version, but that seemed to install with errors because that seemed to indicate that I didn't have a high enough node version, it wanted 6 but said said I only had 4, even though I have 10.15 when I check `node -v`, so pm2 didn't work. I also tried one of the alternative systemd scripts, but got the same error as the recommend autostart. Any ideas how to get this autostart to work?

---

<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: [22 April 2019 07:23 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/2 "2019-04-22T07:23:42Z")

</div>

The `node-red-log` command does  
`sudo journalctl -f -n 25 -u nodered -o cat`  
so you can use that instead. Run it then, in a different terminal, run  
`node-red-start`  
If you still need help then post the result here.

---

<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: [22 April 2019 07:29 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/3 "2019-04-22T07:29:04Z")

</div>

Also, did you see the section "Changing the systemd environment - running as non-Pi user" in the link you posted?

---

<div class="post-metadata">

### Author: ![longunmin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/longunmin/32/2816_2.png) [@longunmin](https://discourse.nodered.org/u/longunmin)
#### Post date: [22 April 2019 11:24 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/4 "2019-04-22T11:24:43Z")

</div>

Thanks, I'll run that log command and see what I get. And yes, I did change the user/group and working environment to be my user, so now its `user=tc1`, group=`tc1` and `workingenv=/home/tc1`. Also, just as an update, I ran the Pi install script, i didn't receive any errors, but now when I try the autostart systemd I get exit code =127, which I believe is command not found?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [22 April 2019 12:03 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/5 "2019-04-22T12:03:23Z")

</div>

if you ran the pi install script (as your tc1 user) then what does `which node-red` report ? and `which node-red-start` as they should both have been installed in /usr/bin.

---

<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: [22 April 2019 12:28 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/6 "2019-04-22T12:28:03Z")

</div>

> [@longunmin](#):
>
> now when I try the autostart systemd I get exit code =127,

Show us what you are entering to do that and what the full result is.  
Running the pi install script will have set the systemd service to run as the user that you were logged in as when you ran the script.

---

<div class="post-metadata">

### Author: ![longunmin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/longunmin/32/2816_2.png) [@longunmin](https://discourse.nodered.org/u/longunmin)
#### Post date: [23 April 2019 01:58 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/7 "2019-04-23T01:58:31Z")

</div>

`which node-red` returns `/home/tc1/.nvm/versions/node/v10.15.3/bin/node-red`  
`which node-red-start` returns `/usr/bin/node-red-start`

the `node-red` command works fine and will start up node-red, the node-red-start up script is the one that produces the errors

@Colin when i run the `node-red-start` command (after I reload the daemon and enable the service) I get the following results (the journalctl command gives the same results):

> Start Node-RED
> 
> Once Node-RED has started, point a browser at http:// 192.XXX.XX.XX:1880  
> On Pi Node-RED works better with the Firefox or Chrome browser
> 
> Use node-red-stop to stop Node-RED  
> Use node-red-start to start Node-RED again  
> Use node-red-log to view the recent log output  
> Use sudo systemctl enable nodered.service to autostart Node-RED at every boot  
> Use sudo systemctl disable nodered.service to disable autostart on boot
> 
> Starting as a systemd service.  
> nodered.service: Failed with result 'exit-code'.  
> nodered.service: Service hold-off time over, scheduling restart.  
> Stopped Node-RED graphical event wiring tool.  
> Started Node-RED graphical event wiring tool.  
> nodered.service: Main process exited, code=exited, status=127/n/a  
> nodered.service: Unit entered failed state.  
> nodered.service: Failed with result 'exit-code'.  
> nodered.service: Service hold-off time over, scheduling restart.  
> Stopped Node-RED graphical event wiring tool.  
> Started Node-RED graphical event wiring tool.  
> nodered.service: Main process exited, code=exited, status=127/n/a  
> nodered.service: Unit entered failed state.  
> nodered.service: Failed with result 'exit-code'.  
> nodered.service: Service hold-off time over, scheduling restart.  
> Stopped Node-RED graphical event wiring tool.  
> Started Node-RED graphical event wiring tool.  
> nodered.service: Main process exited, code=exited, status=127/n/a  
> nodered.service: Unit entered failed state.  
> nodered.service: Failed with result 'exit-code'.  
> nodered.service: Service hold-off time over, scheduling restart.  
> Stopped Node-RED graphical event wiring tool.  
> Started Node-RED graphical event wiring tool.  
> nodered.service: Main process exited, code=exited, status=127/n/a  
> nodered.service: Unit entered failed state.  
> nodered.service: Failed with result 'exit-code'.  
> nodered.service: Service hold-off time over, scheduling restart.  
> Stopped Node-RED graphical event wiring tool.  
> nodered.service: Start request repeated too quickly.  
> Failed to start Node-RED graphical event wiring tool.  
> nodered.service: Unit entered failed state.  
> nodered.service: Failed with result 'start-limit-hit'.

In addition, if I run `sudo systemctl status nodered.service` i get:

> nodered.service - Node-RED graphical event wiring tool  
> Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset:  
> Active: failed (Result: start-limit-hit) since Mon 2019-04-22 21:42:49 EDT; 8  
> Docs: http:// nodered .org/docs/hardware/raspberrypi.html  
> Process: 6947 ExecStart=/usr/bin/env node-red-pi $NODE\_OPTIONS $NODE\_RED\_OPTIO  
> Main PID: 6947 (code=exited, status=127)
> 
> Apr 22 21:42:49 NUC systemd[1]: nodered.service: Unit entered failed state.  
> Apr 22 21:42:49 NUC systemd[1]: nodered.service: Failed with result 'exit-code'.  
> Apr 22 21:42:49 NUC systemd[1]: nodered.service: Service hold-off time over, sch  
> Apr 22 21:42:49 NUC systemd[1]: Stopped Node-RED graphical event wiring tool.  
> Apr 22 21:42:49 NUC systemd[1]: nodered.service: Start request repeated too quic  
> Apr 22 21:42:49 NUC systemd[1]: Failed to start Node-RED graphical event wiring  
> Apr 22 21:42:49 NUC systemd[1]: nodered.service: Unit entered failed state.  
> Apr 22 21:42:49 NUC systemd[1]: nodered.service: Failed with result 'start-limit

---

<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: [23 April 2019 06:15 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/8 "2019-04-23T06:15:27Z")

</div>

You haven't shown us the journalctl command when you run node-red-start in another terminal. That is where the detail of the error will be.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [23 April 2019 06:31 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/9 "2019-04-23T06:31:34Z")

</div>

You are using nvm. That runs as a script in user space. It does not affect the system environment so the version of node available to the system at boot time will be incorrect. If at all possible remove nvm and then reinstall using the script.

---

<div class="post-metadata">

### Author: ![longunmin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/longunmin/32/2816_2.png) [@longunmin](https://discourse.nodered.org/u/longunmin)
#### Post date: [23 April 2019 11:28 UTC](https://discourse.nodered.org/t/autostart-ubuntu-16-04-problems/10408/10 "2019-04-23T11:28:22Z")

</div>

removing nvm via `sudo rm -rf $NVM_DIR` worked! The script works perfectly now, thank you @dceejay and @Colin!
