Overview

PM2 (Process Manager 2) is a daemon process manager that helps manage and keep applications online. Specifically designed for Node.js, PM2 ensures that applications run continuously, restarting them automatically when they crash or encounter errors. This capability is essential for maintaining application uptime in production environments, where unexpected failures can occur.

PM2 is particularly suitable for developers and operations teams deploying Node.js applications that require high availability and efficient resource utilization. It excels in scenarios where applications need to scale across multiple CPU cores without complex infrastructure setup. For example, a web application built with Express.js or Fastify can leverage PM2's cluster mode to distribute incoming requests across multiple instances of the application, thereby improving performance and resilience.

Beyond basic process management, PM2 offers advanced features such as zero-downtime reloads, which allow updates to an application without interrupting service to users. This is achieved by gracefully shutting down old instances and bringing up new ones in sequence. PM2 also includes a monitoring dashboard accessible via the command line or a web interface (PM2 Plus), providing real-time insights into CPU usage, memory consumption, and application logs. Developers can use these tools to diagnose performance bottlenecks and ensure application health.

The system is built to simplify the deployment pipeline. With a few commands, developers can start, stop, restart, and monitor applications, making it easier to manage multiple Node.js services on a single server or across a cluster. Its integration with ecosystem files allows for declarative configuration of application parameters, environment variables, and log settings, streamlining the management of complex deployments. The official PM2 documentation provides comprehensive guides on these configuration options and deployment strategies for Node.js applications.

While PM2's core is focused on Node.js, the principles of process management it embodies are fundamental to server-side application deployment across various languages. For instance, similar needs for process supervision exist in Python with Gunicorn or in Ruby with Puma, demonstrating a common pattern in web server deployments as described by general web performance best practices on web.dev's guide to fast loading times.

Key features

  • Automatic Application Restarts: Automatically restarts Node.js applications if they crash or exit unexpectedly, ensuring continuous operation and high availability (PM2 Runtime Quickstart).
  • Cluster Mode: Enables applications to run in a cluster across all available CPU cores, providing built-in load balancing and improved performance without code changes (PM2 Cluster Mode documentation).
  • Zero-Downtime Reloads: Allows for seamless application updates and deployments without any service interruption, by gracefully restarting processes one by one (PM2 Zero-Downtime Reload guide).
  • Process Monitoring: Provides real-time metrics and logs for CPU, memory, and event loops, accessible through a command-line interface or web dashboard (PM2 Plus web monitoring).
  • Log Management: Centralizes and manages application logs, offering features for log rotation and viewing logs from multiple processes (PM2 Log Management documentation).
  • Declarative Configuration: Supports ecosystem files (JSON, YAML, JS) for defining application parameters, environment variables, and deployment scripts, simplifying setup and management (PM2 Ecosystem File guide).
  • Deployment System: Includes a simple deployment system that automates remote server updates and application restarts, integrating with Git for version control (PM2 Deployment documentation).

Pricing

PM2 offers a free, open-source runtime for core process management, with an optional paid tier (PM2 Plus) for enhanced monitoring and management capabilities.

Product/Tier Features Pricing as of May 2026
PM2 Runtime Process management, automatic restarts, cluster mode, zero-downtime reloads, basic CLI monitoring. Free (open-source)
PM2 Plus (Developer) Web-based monitoring dashboard, custom metrics, error tracking, advanced alerts, up to 10 servers. Starts at €5/month (approx. $5.40 USD/month)
PM2 Plus (Startup) All Developer features, up to 25 servers, team collaboration, priority support. Starts at €19/month (approx. $20.50 USD/month)
PM2 Plus (Business) All Startup features, unlimited servers, enterprise-grade support, custom integrations. Contact sales for pricing

For detailed and up-to-date pricing information, refer to the official PM2 Plus pricing page.

Common integrations

  • Node.js Frameworks: Manages applications built with Express.js, Koa, Hapi, and other Node.js web frameworks, ensuring they run continuously and efficiently (PM2 Quick Start with Node.js).
  • Monitoring Tools: Integrates with PM2 Plus for enhanced web-based monitoring, custom metrics, and alerts.
  • Version Control Systems: Supports deployment directly from Git repositories, automating the update process for applications (PM2 Deployment System).
  • Logging Aggregators: Can output logs in various formats, facilitating integration with external logging services like ELK Stack or Splunk.
  • Containerization Platforms: Often used within Docker containers to manage the Node.js application process, although Docker itself provides process supervision capabilities (PM2 Docker guide).

Alternatives

  • Forever: A simpler CLI tool for ensuring a script runs continuously.
  • systemd: A Linux initialization system and service manager that can manage any type of process, including Node.js applications.
  • Supervisor: A client/server system that allows users to monitor and control a number of processes on UNIX-like operating systems.
  • Nodemon: Primarily a development tool that automatically restarts Node.js applications when file changes are detected.
  • Docker/Kubernetes: For containerized environments, container orchestration platforms themselves provide process management and restart policies.

Getting started

To begin using PM2, you first need to install it globally via npm. After installation, you can use the pm2 start command to launch your Node.js application. PM2 will automatically daemonize the process and keep it running in the background. Here's a basic example for a simple Node.js HTTP server:

First, create a file named app.js:

// app.js
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello fwdgrade from PM2!\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Next, install PM2 globally and start your application:

npm install pm2 -g
pm2 start app.js --name "my-web-app"

The --name flag assigns a friendly name to your process, making it easier to manage. After starting, you can check the status of your application with:

pm2 list

This command will display a table showing your running applications, their status, CPU usage, memory consumption, and other relevant information. To stop the application:

pm2 stop my-web-app

To restart it:

pm2 restart my-web-app

For zero-downtime reloads, which are crucial for updates in production:

pm2 reload my-web-app

This command will gracefully restart your application instances one by one, ensuring continuous service. For more advanced configurations, such as running in cluster mode or defining environment variables, you can use an ecosystem file (PM2 Ecosystem File reference).