PM2 Cluster Mode Breaks In-Memory Sessions / WebSockets Across Workers
Each clustered Node.js worker has an isolated V8 heap; sticky sessions or shared store are absent.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: PM2 Cluster Mode Breaks In-Memory Sessions / WebSockets Across Workers
Platform: Node.js
Common Root Causes:
- Each clustered Node.js worker has an isolated V8 heap; sticky sessions or shared store are absent.
Interactive Diagnostic Checklist
Verified Solutions:
- Externalize sessions/pub-sub to Redis/Valkey/SQLite or run stateful sockets with sticky load balancing.
Safe Diagnostic Command:
pm2 list
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Each clustered Node.js worker has an isolated V8 heap; sticky sessions or shared store are absent. Recommended diagnostic: `pm2 list`. Remediation: Externalize sessions/pub-sub to Redis/Valkey/SQLite or run stateful sockets with sticky load balancing.
Worked Examples
- Run `pm2 list` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-linux-pm2-cluster-port-shared-state · Independently verified: 2026-11-25