Q. What are best practices and caveats when using PM2 in production?

Answer:

  • Use pm2 save after starting processes and use pm2 startup for auto-restart on reboot. 
  • Watch memory leaks — restart processes before limits reached.

  • Use pm2-runtime instead of plain pm2 in Docker containers to keep process in the foreground.

  • Avoid excessive customization — let PM2 handle environment variables and ecosystem files.

  • Be cautious with environment differences — PM2 may alter runtime behavior, so test thoroughly.

  • Monitor logs, health metrics, and handle unhandled exceptions within your app so PM2 doesn’t constantly crash-restart.
Back To Top