Overview
PM2 (Process Manager 2) is an open-source, production-ready process manager for Node.js applications, initially released in 2013. Its primary function is to help developers manage, keep alive, and monitor Node.js applications in production environments. PM2 addresses common challenges in deploying Node.js services, such as ensuring continuous uptime, managing application restarts, and distributing load across multiple CPU cores.
Developers use PM2 to ensure their applications remain running indefinitely, even after unexpected crashes or system reboots. It includes features like automatic application restarts, a built-in load balancer for clustering Node.js applications, and a comprehensive monitoring system. This allows for horizontal scaling of Node.js applications, making effective use of multi-core server architectures without complex manual configuration. The tool is particularly well-suited for scenarios requiring high availability and efficient resource utilization for Node.js services.
Beyond basic process management, PM2 offers capabilities for zero-downtime reloads, allowing updates to be deployed without interrupting active user sessions. This is achieved by gracefully shutting down old application instances only after new ones have successfully started and are ready to handle requests. For enhanced visibility and management, PM2 also provides PM2 Plus, a web-based dashboard that offers real-time monitoring, custom metrics, and remote management across multiple servers. This centralized interface is beneficial for teams managing a fleet of Node.js applications, enabling them to track performance, diagnose issues, and scale their infrastructure more effectively.
The developer experience with PM2 is often cited for its command-line interface (CLI), which simplifies common deployment and management tasks. Its widespread adoption in the Node.js ecosystem is partly due to its ease of integration into existing CI/CD pipelines and its ability to manage various types of Node.js applications, from simple scripts to complex web servers built with frameworks like Express.js or Fastify. PM2 aims to reduce operational overhead for Node.js deployments, allowing developers to focus more on application logic rather than infrastructure concerns.
Key features
- Application Lifecycle Management: Automatically starts, stops, and restarts Node.js applications, ensuring they remain online even after crashes or reboots.
- Zero-Downtime Reloads: Facilitates seamless application updates without service interruptions, by gracefully swapping old instances with new ones when deploying code changes.
- Built-in Load Balancer: Automatically clusters Node.js applications across available CPU cores, improving performance and reliability by distributing incoming requests. This feature simplifies the process of utilizing multi-core server architectures for Node.js applications, as described in the official PM2 clustering documentation.
- Real-time Monitoring: Provides a command-line interface (CLI) dashboard to monitor CPU, memory, and event loop usage, and PM2 Plus offers a web-based dashboard for advanced metrics and remote management.
- Log Management: Aggregates and rotates application logs, simplifying debugging and historical analysis of application behavior.
- Startup Script Generation: Generates system-specific startup scripts (e.g., for systemd, Upstart, or launchd) to automatically start PM2 and its managed applications on server boot, ensuring persistent operation.
- Declarative Configuration: Allows applications to be managed via JSON or YAML configuration files, enabling version control and consistent deployments across environments.
- Module System: Supports extending PM2's functionality with community-contributed modules for additional features like custom alarms, database backups, or advanced logging.
- Remote Management (PM2 Plus): Offers a cloud-based dashboard for managing and monitoring applications across multiple servers from a single interface, including custom metrics and alert configurations.
Pricing
PM2's core process manager is open-source and free to use. PM2 Plus, the monitoring and management dashboard, offers a tiered subscription model as of May 8, 2026. Specific details are available on the PM2 Plus pricing page.
| Plan | Features | Price (as of 2026-05-08) |
|---|---|---|
| PM2 (Core) | Process management, clustering, zero-downtime reloads, CLI monitoring, log management, startup scripts | Free (Open-Source) |
| PM2 Plus - Developer | Up to 1 server, real-time metrics, custom dashboards, alerts, remote actions | Starts at $19/month |
| PM2 Plus - Team | Up to 5 servers, all Developer features, team collaboration, advanced metrics retention | Starts at $49/month |
| PM2 Plus - Business | Custom number of servers, all Team features, enterprise support, dedicated account manager | Custom pricing |
Common integrations
- Node.js Frameworks: Seamlessly manages applications built with popular Node.js frameworks such as Express.js, Fastify, NestJS, and Next.js.
- Monitoring Tools: Integrates with PM2 Plus for enhanced monitoring and management, providing a web-based dashboard for application health and performance metrics.
- CI/CD Pipelines: Can be integrated into continuous integration and continuous deployment workflows to automate application deployment and restarts.
- Containerization: Compatible with Docker environments for managing Node.js applications within containers, often used as the entry point for running Node.js processes.
- System Init Systems: Generates scripts for init systems like systemd, Upstart, and launchd to ensure PM2 and its managed applications start automatically on server boot.
Alternatives
- systemd: A system and service manager for Linux operating systems, often used for managing background processes and services.
- Forever: A simpler CLI tool for ensuring a given script runs continuously and restarts automatically upon failure.
- Supervisor: A client/server system that allows users to monitor and control a number of processes on UNIX-like operating systems.
Getting started
To begin using PM2, you first need to install it globally via npm. After installation, you can start managing your Node.js applications with simple commands. Here's a basic example:
# Install PM2 globally
npm install pm2 -g
# Create a simple Node.js application (app.js)
cat > app.js << EOF
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 Node.js with PM2!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
EOF
# Start your Node.js application with PM2
pm2 start app.js --name "my-node-app"
# Check the status of your applications managed by PM2
pm2 list
# Monitor your application in real-time
pm2 monit
# Stop the application
pm2 stop my-node-app
# Delete the application from PM2's process list
pm2 delete my-node-app
# Save the current process list so they restart on server boot
pm2 save
# Generate a startup script to ensure PM2 starts on boot
pm2 startup
This sequence of commands demonstrates how to install PM2, start a Node.js application, monitor its status, and manage its lifecycle. The pm2 save command is crucial for persisting your application configurations across server reboots, ensuring that PM2 automatically restarts your applications. The pm2 startup command generates a system-specific script that registers PM2 with your operating system's init system (like systemd on Linux), allowing PM2 itself to start automatically when the server boots up, and then in turn, restart all saved applications. For more detailed instructions and advanced configurations, consult the PM2 quick start documentation.