Unitech/pm2 · error · Error

Init system not found

Error message

Init system not found

What it means

Thrown by CLI.uninstallStartup (pm2 unstartup / pm2 startup --remove). PM2 tries to auto-detect the init system by probing PATH for known tools (systemctl, update-rc.d, chkconfig, rc-update, launchctl, sysrc, rcctl, svcadm) via detectInitSystem(). If none are found and the caller passed no explicit platform, platform stays null and the command aborts.

Source

Thrown at lib/API/Startup.js:90

    var commands;
    var that = this;
    var actual_platform = detectInitSystem();
    var user = opts.user || process.env.USER || process.env.LOGNAME; // Use LOGNAME on Solaris-like systems
    var service_name = (opts.serviceName || 'pm2-' + user);
    var openrc_service_name = 'pm2';
    var launchd_service_name = (opts.serviceName || 'pm2.' + user);

    if (!platform)
      platform = actual_platform;
    else if (actual_platform && actual_platform !== platform) {
      Common.printOut('-----------------------------------------------------------')
      Common.printOut(' PM2 detected ' + actual_platform + ' but you precised ' + platform)
      Common.printOut(' Please verify that your choice is indeed your init system')
      Common.printOut(' If you arent sure, just run : pm2 startup')
      Common.printOut('-----------------------------------------------------------')
    }
    if (platform === null)
      throw new Error('Init system not found')

    if (!cb) {
      cb = function(err, data) {
        if (err)
          return that.exitCli(cst.ERROR_EXIT);
        return that.exitCli(cst.SUCCESS_EXIT);
      }
    }

    if (process.getuid() != 0) {
      return isNotRoot('unsetup', platform, opts, cb);
    }

    if (fs.existsSync('/etc/init.d/pm2-init.sh')) {
      platform = 'oldsystem';
    }

    switch(platform) {

View on GitHub (pinned to 31adee8048)

Solutions

  1. Pass the platform explicitly: `pm2 unstartup systemd` (or upstart, launchd, systemv, openrc, rcd, rcd-openbsd, smf).
  2. Install the init tooling for your distribution so detection succeeds.
  3. Run the command on a real host where the init tool is present.

Example fix

// before
pm2 unstartup
// after
pm2 unstartup systemd
Defensive patterns

Strategy: validation

Validate before calling

const which = require('which');
const tools = ['systemctl','update-rc.d','chkconfig','rc-update','launchctl','sysrc','rcctl','svcadm'];
const detected = tools.find((t) => which(t, { nothrow: true }));
if (!detected && !process.env.PM2_STARTUP_PLATFORM) {
  throw new Error('No init system detected; pass an explicit platform (e.g. systemd)');
}

Prevention

When it happens

Trigger: Running `pm2 unstartup` (or uninstallStartup programmatically) on a host where none of the init tools are on PATH and no platform argument is supplied.

Common situations: Minimal containers (e.g. Alpine without openrc-utils installed), exotic/older OSes, WSL environments, CI runners without init tooling.

Related errors


AI-assisted analysis of Unitech/pm2@31adee8048 (2026-08-13). Data as JSON: /api/errors/d5eec833d73159dd. Report an issue: GitHub.