PM2 Not Picking Up Updated `.env` or `ecosystem.config.js` Variables

`pm2 restart` reuses cached process environment variables unless `--update-env` is passed.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: PM2 Not Picking Up Updated `.env` or `ecosystem.config.js` Variables Platform: Node.js
Common Root Causes:
  • `pm2 restart` reuses cached process environment variables unless `--update-env` is passed.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Run `pm2 reload ecosystem.config.js --update-env` (or delete and recreate the process).
Safe Diagnostic Command:
pm2 env <id>
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

`pm2 restart` reuses cached process environment variables unless `--update-env` is passed. Recommended diagnostic: `pm2 env <id>`. Remediation: Run `pm2 reload ecosystem.config.js --update-env` (or delete and recreate the process).

Worked Examples

  • Run `pm2 env <id>` 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-node-pm2-env-not-reloading · Independently verified: 2026-11-25

Related Resources