Automatically Start a NodeJS Application at Boot on a Raspberry Pi

The Raspberry Pi (running Raspian) makes a perfect host for running NodeJS applications.

The current version of Raspbian (based on Debian Linux) uses the systemd init system. (April 2016)

I use the production manager PM2 to handle to launching (and restarting) of NodeJS applications.

PM2 may be installed as follows:

sudo npm install pm2 -g

To start a NodeJS application e.g. app.js use the following command

pm2 start app.js

PM2 has the ability to create the start-up command so that application automatically start at boot.

First save the list running applications with

sudo pm2 save

Given that the Raspberry PI uses the systemd init architecture and that the  primary user is typically the account pi Рuse the following command to auto start the saved process list at boot:

sudo pm2 startup systemd -u pi


Leave a Reply