Node js server on Raspberry with PM2 & Keymetrics

I have a Raspberry Pi 3, so why don't use this power efficient device to create my personal Node.js server? In this article we will see how to make it possible with also a fancy and useful user interface!


To setup your Node js server you need Node installed on your device (obviusly!)

So ssh into the rasp and type:

curl -sL | sudo -E bash -  
sudo apt-get install -y nodejs  

while node is installing we have the time to talk about the remote monitoring: Is a security best practice to forbid the remote ssh access, if you need to manage your node apps from remote location you will need a secure manager.

Here comes PM2 and Keymetrics.

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

npm install -g pm2  

Keymetrics provides a fancy UI of pm2 with a nice free plan.

Open the Keymetric App and register your account.

Login and create a new bucket (only one is available for the free plan).

Recap Now we have:

  • Node.js on Raspberry
  • pm2 installed globally on Raspberry
  • Keymetrics account with bucket configured

Link the raspberry to Keymetrics

The bucket dashboard give us an hint on what to do next, the pm2 link command:

pm2 link sintax:

pm2 link {private_key} {public_key} [server_name]  

Enable server monitoring

pm2 install pm2-server-monit  

This module is a complete monitor for your raspberry, i've been using this from a long time and is always very useful!


git clone  
cd app-playground  
pm2 start app.js --watch  

This is a demo application made by Keymetrics, if you don't have a Node.js application can be very useful.

If you find this article useful or you have some suggestions please Tweet me!