Table of Contents
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

How to Setup PM2 on Ubuntu 16.04

Last Updated: Fri, Apr 13, 2018
Linux Guides Node.js Ubuntu
Archived content

This article is outdated and may not work correctly for current operating systems or software.

PM2 is a very popular Node process manager that makes running NodeJS applications easy. PM2 makes it easy to restart apps, automatically restart crashed applications and automatically start applications after a server reboot.

This article will teach you how to install PM2 and run basic setup on Ubuntu 16.04.


  • NodeJS and NPM - Learn to install here (ExpressJS is not strictly required)

This tutorial also assumes that you are logged in as root. If you do not have access to the root user, add sudo to the start of all commands.

Installing PM2 via NPM

Installing PM2 is very simple, and can be done in a single line of code.

npm install -g pm2

Setting up PM2 to run your project

Start by navigating to your project directory. You can do this by typing the cd command followed by the directory.

cd /root/project

To start your app, type the command pm2 start followed by your app's location.

pm2 start /project/app.js

You will see a table that resembles the following image.

Running PM2 as a service

After running the code above, it is recommended that you setup PM2 as a service so that it can start when the server starts.

env PATH=$PATH:/usr/local/bin pm2 startup -u root

Make sure to replace root with your username if you aren't using the root user.

Want to contribute?

You could earn up to $600 by adding new articles