
Running n8n without a process manager is like driving without seatbelts. It works fine until it doesn’t. One server hiccup, one closed terminal, one unexpected crash, and your workflows disappear.
This step-by-step guide shows you exactly how to use PM2 for persistent, monitored n8n deployments that recover automatically from any failure.
Monitoring n8n with PM2 requires a VPS that delivers stable performance and reliable process management support. The comparison table below highlights VPS hosting providers that handle long running automation workloads efficiently. These providers make it easier to monitor uptime, restart processes automatically, and maintain workflow stability. Explore our recommended VPS hosting options.
VPS Hosting Providers Optimized for Monitoring and Managing n8n Processes
| Provider | User Rating | Recommended For | |
|---|---|---|---|
![]() | 4.8 | Scalability | Visit Kamatera |
![]() | 4.6 | Affordability | Visit Hostinger |
![]() | 4.7 | Developers | Visit IONOS |
Why You Should Be Using PM2 to Monitor n8n Processes
PM2 is a production ready process manager for Node.js applications with over 100 million downloads. That’s not a typo. It’s become the default choice for developers who need their applications running 24/7 without babysitting.
Here’s what makes it essential for n8n deployments:
- Automatic recovery: Your workflows restart after crashes without intervention.
- Boot persistence: The n8n service starts automatically when your server reboots.
- Environment variable management: Centralized configuration for scalable automation.
- Resource monitoring: Real-time CPU and memory tracking at your fingertips.
Without PM2, closing your terminal kills your running n8n instance. With it, your automation tools keep working whether you’re watching or not.
A Developer Friendly Alternative to Docker Compose
Docker Compose works great for complex microservice architectures. But for straightforward n8n deployments? It’s often overkill.
PM2 operates at a different layer than containerization. It manages your application lifecycle directly within the operating system. No container networking. No image builds. No orchestration headaches.
Teams that prefer single-server deployments love PM2 because it handles scaling efficiently without the steep learning curve. You get full control over your processes without needing container expertise.
For a deeper comparison, check our guide on Docker Compose vs Bare-Metal VPS to understand when each approach makes sense.
Bypassing the Need to Install Docker
Small to medium deployments don’t need containerization overhead. Docker adds infrastructure complexity that PM2 eliminates entirely.
The resource savings matter, especially on VPS environments. You’re not running a container runtime consuming RAM that could power your workflows instead. This makes PM2 highly cost-effective for teams seeking cheap n8n hosting solutions.
If you want to install Docker later for other projects, nothing stops you. But for running n8n reliably? PM2 handles everything you need.
Preparing for Your n8n Installation
Step 1: How to Install Node.js

Before anything else, your server needs Node.js and npm installed. The n8n installation requires Node.js version 14.15 or higher.
Start by updating your system packages:
sudo apt update
Pro Tip: Use Node Version Manager to manage multiple Node.js versions. It prevents system conflicts and lets you switch versions instantly. Install it, then run:
nvm install 18
nvm use 18
This approach gives you flexibility when different projects need different node versions.
Step 2: How to Install PM2
With Node.js active, install PM2 globally using npm:
sudo npm install -g pm2
The above command makes PM2 accessible system-wide. Any user can execute PM2 commands from anywhere on your server.
Verify the installation worked:
pm2 –version
You should see a version number. If not, check your npm permissions.
Step 3: How to Install n8n Globally for the Latest Version
Installing n8n globally is the recommended approach for process manager deployments. Run:
npm install -g n8n
This suggested command installs the latest version of n8n and makes it available system-wide. PM2 can easily locate the executable when you start access to your automation platform.
Once installed, start n8n manually to verify it works:
n8n start
The web interface becomes accessible via localhost:5678 on your local machine or IP_ADDRESS:5678 on a server. Stop it with Ctrl+C once you’ve confirmed it’s working.
Setting Up the n8n Service with PM2
Creating Your First Configuration File
Ecosystem configuration files provide a declarative way to manage your n8n instance. Create a file called ecosystem.config.js:
module.exports = {
apps: [{
name: ‘n8n’,
script: ‘n8n’,
args: ‘start’,
autorestart: true,
max_memory_restart: ‘300M’,
env: {
EXECUTIONS_DATA_PRUNE: ‘true’,
EXECUTIONS_DATA_MAX_AGE: ‘168’,
DB_SQLITE_VACUUM_ON_STARTUP: ‘true’,
N8N_BASIC_AUTH_ACTIVE: ‘true’,
N8N_BASIC_AUTH_USER: ‘admin’,
N8N_BASIC_AUTH_PASSWORD: ‘your-secure-password’,
GENERIC_TIMEZONE: ‘America/New_York’
}
}]
};
This config file centralizes all deployment settings. You can manage multiple applications simultaneously and track changes through version control.
Key production settings explained:
- EXECUTIONS_DATA_PRUNE: true removes old execution data automatically.
- EXECUTIONS_DATA_MAX_AGE: 168 retains data for one week.
- autorestart: true ensures recovery after crashes.
Managing Environment Variables Securely

Ecosystem files let you set environment variables that override default configurations. Essential variables include authentication settings, timezone configuration, and database connections.
Security Note: Never commit sensitive variables to version control. Use secure configuration management practices. Rotate production credentials regularly.
For advanced configurations involving secrets, consider using environment-specific config files or external secret managers.
Launching Your n8n Instance
Start your n8n with PM2 using the following command:
pm2 start ecosystem.config.js –update-env
The –update-env flag ensures environment variables apply correctly. Without it, PM2 might use cached values from previous runs.
Save your configuration to survive reboots:
pm2 save
Then configure the startup script:
pm2 startup
This command asks you to run a specific sudo systemctl command. Copy and execute it. Your n8n instance now starts automatically after server reboots.
Comprehensive Monitoring Capabilities
Real-Time Resource Tracking
The pm2 monit command opens a live terminal dashboard. You’ll see CPU usage, memory consumption, and process status updating in real-time.
| Monitoring Metric | Purpose | Use Case | Update Frequency |
|---|---|---|---|
| CPU Usage | Track processor utilization | Identify CPU-intensive workflows | Real-time |
| Memory Consumption | Monitor RAM usage | Prevent out-of-memory crashes | Real-time |
| Process Status | Verify running/stopped state | Confirm operational status | Real-time |
| Uptime | Track continuous operation | Detect excessive restarts | Real-time |
| Restart Count | Monitor process stability | Identify recurring crashes | Real-time |
| Process ID (PID) | Identify process instance | Debug and troubleshoot | On status change |
Check your process list anytime:
pm2 list
This shows all managed processes with their current status, memory usage, and restart counts.
Memory-Based Monitoring and Thresholds
Workflow executions consume substantial memory when processing large datasets. Think Google Sheets imports with thousands of rows or AI agents analyzing documents.
The max_memory_restart option lets you specify limits:
max_memory_restart: ‘300M’
PM2’s internal memory monitoring checks every 30 seconds. Restarts won’t be instantaneous when thresholds are exceeded, but they prevent catastrophic failures.
For deeper performance tuning, explore our guide on optimizing Node.js memory for n8n deployments.
Advanced Logging and Health Checks
Real-Time Log Streaming and Rotation
PM2 stores separate output and error logs in $HOME/.pm2/logs by default. Stream logs in real-time:
pm2 logs n8n
Add –lines 50 to view only recent events.
For log management at scale, install pm2-logrotate:
pm2 install pm2-logrotate
This automatically generate compressed archives of older logs, saving disk space.
Control n8n’s internal logging with the N8N_LOG_LEVEL variable. Options include silent, error, warn, info, and debug.
Verifying System Readiness
Health endpoints help external monitoring tools verify your instance is running:
- /healthz returns HTTP 200 when reachable.
- /healthz/readiness confirms active database connections and completed migrations.
Enable the N8N_METRICS variable to expose granular performance data for tools like Prometheus.

Restart Strategies and System Resilience
Automatic and Exponential Backoff Restarts
PM2 offers multiple restart strategies for different failure scenarios:
| Restart Strategy | Purpose | Configuration | Best Use Case |
|---|---|---|---|
| Automatic Restart | Recovery from crashes | Default behavior | All deployments |
| Memory-Based Restart | Reclaim memory leaks | max_memory_restart: “300M” | High-volume workflows |
| Cron-Based Restart | Scheduled maintenance | cron_restart: “0 2 * * *” | Daily resets |
| Exponential Backoff | Handle cascading failures | exp_backoff_restart_delay: 100 | External dependency issues |
| Watch-Based Restart | Development iteration | watch: true | Development only |
Use stop_exit_codes: [0] to skip automatic restarts for intentional shutdowns.
Zero-Downtime Reloads
Production environments need updates without dropping webhook requests. Use PM2 restart n8n with the reload command:
pm2 reload n8n
This performs zero-downtime reloads by sequentially restarting instances. Applications must handle SIGINT signals for graceful shutdowns.
Scaling with Cluster Mode
Maximizing CPU Utilization
Node.js runs single-threaded by default. Multi-core servers sit mostly idle. Fix this with cluster mode:
instances: ‘max’
PM2 spawns one instance per CPU core. Intelligent round-robin load balancing distributes requests evenly.
Understanding when to graduate to full worker-queue architecture matters. See our guide on Queue Mode vs Regular Mode for scaling decisions.
Database and Security Configurations
Moving from SQLite to PostgreSQL
The default SQLite database degrades during concurrent access. PostgreSQL handles multiple connections without breaking a sweat.
Migration steps:
- Stop PM2: pm2 stop n8n
- Update database environment variables in your configuration file
- Restart: pm2 restart n8n –update-env
The pm2 update command ensures correct credential usage.
SSL/TLS with Nginx

Secure deployments require encryption. Nginx acts as a reverse proxy, listening on port 443 and forwarding to n8n on port 5678.
Configure your Nginx server block, then restart Nginx:
sudo systemctl restart nginx
Let’s Encrypt provides free SSL certificates. Set the WEBHOOK_TUNNEL_URL variable to ensure external systems trigger workflows via HTTPS.
Protect your encryption key by never committing it to repositories.
Choosing the Right VPS for Your Setup
Your PM2-managed n8n deployment needs reliable infrastructure. A properly configured server makes everything we’ve discussed work smoothly.
When selecting a VPS provider, consider RAM availability, CPU cores for cluster mode, and SSD storage for database performance. Linux platforms significantly outperform Windows, consuming less RAM and lowering costs.
Browse VPS options that match your automation workload. Whether you’re running a Raspberry Pi experiment or production workflows, the right hosting foundation matters.
For n8n-specific recommendations, check our guide to the best n8n hosting providers.
Troubleshooting Common Issues
Fixing Authentication and Path Errors
Basic authentication failures often stem from improper environment variable syntax. Always use –update-env when restarting and run pm2 save afterward.
Windows Specifics: PM2 may fail to locate binaries. Execute commands directly from C:\Users\%AppData%\Roaming\npm\node_modules\n8n\bin.
Global installations with root privileges cause permission errors. Always install PM2 and n8n as the user who will run the services.
Managing Memory Limits Effectively
Never set memory limits equal to your total server RAM. The operating system and PM2 need overhead too.
Best Practice: Configure max_memory_restart to 75-80% of available memory. On a 2GB server, that’s roughly 1.5GB maximum.
Performance Benchmarking and Backups
Single-Instance vs. Multi-Instance Throughput
A single n8n instance achieves up to 220 workflow executions per second on modest hardware. Latency increases under concurrent load, but self hosted deployments handle most use cases comfortably.
Queue mode architecture sustains higher throughput by separating webhook receivers from workers. This matters when you build automation workflows at enterprise scale.
Automated Workflow Backups
Implement scheduled workflows to export credentials and data to S3-compatible storage. Regular PostgreSQL backups protect against corruption.
Use VACUUM commands periodically to reclaim disk space from pruned execution records. Automate tasks like this through n8n itself for maximum efficiency.
Considering alternatives? Our n8n vs Node-RED comparison covers similar deployment patterns.
Conclusion
PM2 transforms fragile n8n sessions into production-grade automation infrastructure. You’ve learned to install, configure, monitor, and scale your instance with confidence. Memory limits prevent crashes. Cluster mode maximizes hardware. PostgreSQL and Nginx handle production demands.
Your workflows now survive reboots, recover from failures, and scale with your needs. That’s the power of proper process management.
Next Steps: What Now?
- Create your ecosystem configuration file with production-ready settings.
- Set up PM2 startup scripts for automatic recovery after server reboots.
- Configure memory limits appropriate for your server’s resources.
- Migrate from SQLite to PostgreSQL for better concurrent performance.
- Implement SSL/TLS through Nginx for secure webhook traffic.
- Schedule automated backups of your workflows and database.
- Enable new features like metrics endpoints for external monitoring.



