{"record":{"id":"a8fa8d9161f5c23e","repo":"phacility/phabricator","slug":"unable-to-start-notifications-server-because-it-is","errorCode":null,"errorMessage":"Unable to start notifications server because it is already running. Use `%s` to restart it.","messagePattern":"Unable to start notifications server because it is already running\\. Use `(.+?)` to restart it\\.","errorType":"exception","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php","lineNumber":354,"sourceCode":"    $extension = new ReflectionExtension($ext);\n    foreach ($extension->getFunctions() as $function) {\n      $function = $function->name;\n      if (!function_exists($function)) {\n        echo pht(\n          'ERROR: The PHP function %s is disabled. You must '.\n          'enable it to run Aphlict on this machine.',\n          $function.'()').\"\\n\";\n        exit(1);\n      }\n    }\n  }\n\n  final protected function willLaunch() {\n    $console = PhutilConsole::getConsole();\n\n    $pid = $this->getPID();\n    if ($pid) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to start notifications server because it is already '.\n          'running. Use `%s` to restart it.',\n          'aphlict restart'));\n    }\n\n    if (posix_getuid() == 0) {\n      throw new PhutilArgumentUsageException(\n        pht('The notification server should not be run as root.'));\n    }\n\n    // Make sure we can write to the PID file.\n    if (!$this->debug) {\n      Filesystem::writeFile($this->getPIDPath(), '');\n    }\n\n    // First, start the server in configuration test mode with --test. This\n    // will let us error explicitly if there are missing modules, before we","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php#L336-L372","documentation":"Thrown by willLaunch() when getPID() returns a live PID from the PID file, meaning an Aphlict instance appears to already be running. Start is refused to avoid two daemons fighting over the same ports and PID file; the message points at `aphlict restart` as the supported path.","triggerScenarios":"Running `bin/aphlict start` (or debug without a prior stop) while a previous instance is up; also when a stale PID file names a PID that happens to belong to any currently running process.","commonSituations":"Server rebooted and the daemon was started by an init script while an operator manually starts it too; a previous crash left a stale PID file whose recorded PID was reused by an unrelated process.","solutions":["Use `bin/aphlict restart` which stops the running instance before starting","If you are sure nothing is running, remove the stale PID file (path from config 'pidfile') and start again","Verify with `ps -p <pid-from-pidfile> -f` whether the recorded PID is really an aphlict/node process before deleting anything"],"exampleFix":"# before\n$ bin/aphlict start   # -> already running\n# after\n$ bin/aphlict restart\n# or, if the PID file is stale:\n$ cat /var/run/aphlict/aphlict.pid; ps -fp $(cat /var/run/aphlict/aphlict.pid)\n$ rm /var/run/aphlict/aphlict.pid && bin/aphlict start","handlingStrategy":"try-catch","validationCode":"$pid = phutil_getenv('APHLECT_PID');\n// shell-level pre-check:\n$pid = trim(@file_get_contents('/var/run/aphlict/aphlict.pid'));\nif ($pid && posix_kill((int)$pid, 0)) {\n  // already running: use restart instead of start\n}","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->willLaunch();\n} catch (PhutilArgumentUsageException $ex) {\n  if (preg_match('/already running/', $ex->getMessage())) {\n    // benign: switch to `aphlict restart` instead of start\n  }\n}","preventionTips":["Always use `aphlict restart` in scripts; it handles the running case cleanly","After crashes or reboots, verify and clean stale PID files before automated start"],"tags":["aphlict","process-management","pidfile","phabricator"],"backgroundTag":"service-already-running","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}