In a previous article I explained how you can install Node-RED on your Ubuntu server. Quite a few people are wondering how you can configure your server to start Node-RED automatically on system boot. That’s what this article is all about: start Node-RED as a service when the server starts.

The procedure is simple, as the Node-RED team is providing us the startup scripts.

1
2
3
4
5
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start -O /usr/bin/node-red-start
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop -O /usr/bin/node-red-stop
sudo chmod +x /usr/bin/node-red-st*
sudo systemctl daemon-reload

Unfortuntely we’re not ready yet. The script are written for a Raspberry Pi system. We need to alter a script to make sure Node-RED runs an axisting user on the server.

1
sudo nano /lib/systemd/system/nodered.service

Find the following lines and change the user and group to an existing user.

1
2
3
User={your_user_name_here}
Group={your_user_name_here}
WorkingDirectory=/home/{your_user_name_here}

Now the only thing left is to enable the service.

1
sudo systemctl enable nodered.service

That’s it! Restart your server and verify Node-RED is starting on system boot.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website

This site uses Akismet to reduce spam. Learn how your comment data is processed.