Node-RED: installation and configuration on Ubuntu 16.04 LTS

node-red ubuntu 16.04 lts
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email
Share on whatsapp
Table of Contents

In previous tutorials we have seen how to install Node-RED on Windows, MacOS and Raspbian (Raspberry PI). In this tutorial we will install Node-RED on Ubuntu 16.04 LTS (Long Term Support) on an Atom-based mini PC. We will install Node.js, npm (the package manager of Node.js) and Node-RED.

Install Node.js and npm

Installing Node.js is very simple on Ubuntu 16.04 LTS because it is included in the default repositories. In a Terminal, run the following command:

sudo apt-get install nodejs-legacy

This command installs Node.js version v4.2.x LTS which means that this version will be maintained for another 30 months from the release date, ie October 12, 2015.

After installation, check the installed version.

$ node -v

Node.js uses a package manager called npm (Node Package Manager). It allows you to install and manage packages. Since Node-RED is a “over-layer graphics” of Node.js, it is necessary to install it.

sudo apt-get install npm

When the installation is complete, check the version. If the version is returned without error, you can continue the installation of Node-RED.

$ npm -v

Install Node-RED on Ubuntu (16.04 LTS +)

Node-RED installs using the npm package manager. We will take advantage of this to install the node-red-admin module which adds some administration tools for Node-RED.

sudo npm install -g --unsafe-perm node-red node-red-admin

By default, npm installs the packages in the current directory. The -g option installs packages globally, meaning that they will be available for all Node.js. In this case, they are installed in the / usr / local / bin directory. The –unsafe-perm option overrides any errors that may occur during installation. For example, when certain modules are to be compiled at the time of installation.

Node-RED uses port 1880 by default. It must therefore be authorized.

sudo ufw allow 1880

And now, you can start Node-RED with the command node-red .

To access it, open a web browser and enter the following URL in the address bar http://localhost:1880

node-red ubuntu 16.04 lts

Run Node-RED automatically at startup

To be able to start Node-RED automatically when Ubuntu starts, we will create a script that will be launched by systemd.

Open an empty file named node-red.service

sudo nano /etc/systemd/system/node-red.service

Paste the contents of this script and then replace the USER key with your username. Save the file with CTRL+X and then Y.


ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v

# log output to syslog as 'node-red'

# non-root user to run as


Some explanations on the configuration:

  • The first section (Unit) indicates that the service should start after the network and the syslog service are up and running.
  • The [service] section. ExecStart indicates the program started and the resources allocated for its operation.
  • Restart = on-failure to restart Node-RED in case of crash
  • The events will be identified in the system log (StandardOutput = syslog) with the node-red identifier.

Now that the configuration file is ready, we tell systemd to run it at startup.

sudo systemctl enable node-red

Let’s start it manually (Do not forget to stop Node-RED if another instance is already running).

sudo systemctl start node-red

Now that Node-RED works as a service, you have to go through systemd to stop it manually.

sudo systemctl stop node-red
Click to rate this post!
[Total: 0 Average: 0]

Thanks for your reading

Did you like this project ? Don't miss any more projects by subscribing to our weekly newsletter!

Are you having a problem with this topic?

Maybe someone has already found the solution, visit the forum before asking your question
1 Comment
  1. Hi I tried running node -red as service using the service file given above, But after stating the node-red service by command

    sudo systemctl start node-red
    and when checking the status its showing failed status with two errors
    1). node-red.service:Start request repeated too quickly
    2). node-red.service: Failed with result “exit-code’

    Leave a Reply

    Read more
    Recent posts on the Forum
    DIY Projects
    DIY Projects
    %d bloggers like this: