Skip to content
Node.js Production Process Manager with a built-in Load Balancer.
Branch: master
Clone or download
Latest commit 359c8c2 Jul 2, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github fix: remove trailing spaces Jul 2, 2018
bin fix: pm2 conf display whole configuration Apr 5, 2019
examples deleted double semi Nov 19, 2018
lib fix: systemd restart PM2 only on-failure #4157 Apr 5, 2019
packager feat: systemd restart on failure #3956 Dec 27, 2018
pres chore: btn Jul 4, 2018
test improv: serve feat, spa + basic auth Mar 27, 2019
types fix: #3883 fix typings for max_memory_restart and add wait_ready Aug 29, 2018
.bithoundrc .bithoundrc Jan 25, 2018
.changelogrc chore: upgrade to 3.1.1 Sep 10, 2018
.drone.yml fix: remove trailing spaces Jul 2, 2018
.editorconfig chore: remove duplicate configs in .editorconfig Jul 2, 2018
.gitattributes Fix shell scripts EOL on Windows Jul 5, 2017
.gitignore feat: add pm2 profile:cpu / pm2 profile:mem Feb 18, 2019
.npmignore fix: do not ignore child pres folder Jul 17, 2018
.travis.yml chore: remove unused package + remove node 4 testing on travis Apr 5, 2019 doc: wipe advanced readme Jan 2, 2019 pm2@3.5.0 Apr 8, 2019 fix: remove trailing spaces Jul 2, 2018
GNU-AGPL-3.0.txt Update license year range to 2016 Jan 18, 2016
LICENSE README update - LICENSE Sep 4, 2014
Makefile (deploy) add deploy script Dec 9, 2016 docs: update info links Jul 2, 2019 fix: remove trailing spaces Jul 2, 2018
constants.js feat: re-implement pm2 plus cli Jan 7, 2019
index.js (startup refactor) Dec 4, 2016
package.json pm2@3.5.1 - do not rely on optionalDependency #4289 May 23, 2019
paths.js refactor: use @pm2/js-api for login/register on via CLI May 30, 2018

pm2 logo

P(rocess) M(anager) 2
Runtime Edition

npm version node version Build Status

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.

Starting an application in production mode is as easy as:

$ pm2 start app.js

PM2 is constantly assailed by more than 1800 tests.

Official website:

Works on Linux (stable) & macOS (stable) & Windows (stable). All Node.js versions are supported starting Node.js 4.X.


Installing PM2

$ npm install pm2 -g

npm is a builtin CLI when you install Node.js - Installing Node.js with NVM

Start an application

You can start any application (Node.js, Python, Ruby, binaries in $PATH...) like that:

$ pm2 start app.js

Your app is now daemonized, monitored and kept alive forever.

More about Process Management

Container Support

With the drop-in replacement command for node, called pm2-runtime, run your Node.js application in a hardened production environment. Using it is seamless:

RUN npm install pm2 -g
CMD [ "pm2-runtime", "npm", "--", "start" ]

Read More about the dedicated integration

Managing Applications

Once applications are started you can manage them easily:

Process listing

To list all running applications:

$ pm2 list

Managing apps is straightforward:

$ pm2 stop     <app_name|id|'all'|json_conf>
$ pm2 restart  <app_name|id|'all'|json_conf>
$ pm2 delete   <app_name|id|'all'|json_conf>

To have more details on a specific application:

$ pm2 describe <id|app_name>

To monitor logs, custom metrics, application information:

$ pm2 monit

More about Application Management

Cluster Mode: Node.js Load Balancing & Zero Downtime Reload

The Cluster mode is a special mode when starting a Node.js application, it starts multiple processes and load-balance HTTP/TCP/UDP queries between them. This increase overall performance (by a factor of x10 on 16 cores machines) and reliability (faster socket re-balancing in case of unhandled errors).

Starting a Node.js application in cluster mode that will leverage all CPUs available:

$ pm2 start api.js -i <processes>

<processes> can be 'max', -1 (all cpu minus 1) or a specified number of instances to start.

Zero Downtime Reload

Hot Reload allows to update an application without any downtime:

$ pm2 reload all

Seamlessly supported by all major Node.js frameworks and any Node.js applications without any code change:

Framework supported

More informations about how PM2 make clustering easy

Terminal Based Monitoring


Monitor all processes launched straight from the command line:

$ pm2 monit

Log Management

To consult logs just type the command:

$ pm2 logs

Standard, Raw, JSON and formated output are available.


$ pm2 logs APP-NAME       # Display APP-NAME logs
$ pm2 logs --json         # JSON output
$ pm2 logs --format       # Formated output

$ pm2 flush               # Flush all logs
$ pm2 reloadLogs          # Reload all logs

More about log management

Startup Scripts Generation

PM2 can generates and configure a Startup Script to keep PM2 and your processes alive at every server restart.

Init Systems Supported: systemd, upstart, launchd, rc.d

# Generate Startup Script
$ pm2 startup

# Freeze your process list across server restart
$ pm2 save

# Remove Startup Script
$ pm2 unstartup

More about Startup Scripts Generation

PM2 Modules

PM2 embeds a simple and powerful module system. Installing a module is straightforward:

$ pm2 install <module_name>

Here are some PM2 compatible modules (standalone Node.js applications managed by PM2):

pm2-logrotate automatically rotate logs and limit logs size
pm2-server-monit monitor the current server with more than 20+ metrics and 8 actions

Updating PM2

# Install latest PM2 version
$ npm install pm2@latest -g
# Save process list, exit old PM2 & restore all processes
$ pm2 update

PM2 updates are seamless

PM2+ Monitoring

If you manage your NodeJS app with PM2, PM2+ makes it easy to monitor and manage apps across servers. Feel free to try it:

Discover the monitoring dashboard for PM2

Thanks in advance and we hope that you like PM2!






PM2 is made available under the terms of the GNU Affero General Public License 3.0 (AGPL 3.0). For other licenses contact us.

You can’t perform that action at this time.