{"record":{"id":"1485860e7b38ab75","repo":"neoclide/coc.nvim","slug":"previous-start-failed-can-t-restart-server","errorCode":null,"errorMessage":"Previous start failed. Can't restart server.","messagePattern":"Previous start failed\\. Can't restart server\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/language-client/client.ts","lineNumber":1063,"sourceCode":"        reject(error)\n      }\n    }\n    return this._onStart\n  }\n\n  public start(): Promise<void> & Disposable {\n    let p: any = this._start()\n    p.dispose = () => {\n      if (this.needsStop()) {\n        void this.stop()\n      }\n    }\n    return p\n  }\n\n  private async $start(): Promise<Connection> {\n    if (this.$state === ClientState.StartFailed) {\n      throw new Error(`Previous start failed. Can't restart server.`)\n    }\n    await this._start()\n    const connection = this.activeConnection()\n    if (connection === undefined) {\n      throw new Error(`Starting server failed`)\n    }\n    return connection\n  }\n\n  private handleConnectionEvents(connection: Connection) {\n    connection.onNotification(LogMessageNotification.type, message => {\n      switch (message.type) {\n        case MessageType.Error:\n          this.error(message.message)\n          break\n        case MessageType.Warning:\n          this.warn(message.message)\n          break","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/language-client/client.ts#L1045-L1081","documentation":"Thrown by LanguageClient.$start() when the client's state is ClientState.StartFailed, meaning a previous start attempt failed (e.g. the server process crashed on launch) and the library refuses to retry with the same failed client. The failed state is sticky by design to surface the original configuration problem.","triggerScenarios":"Calling start()/restart after a server failed to launch (bad command path, missing executable, immediate crash, invalid initialization), then invoking any operation that triggers $start again (a request, notification, or restart).","commonSituations":"Language server command not installed or not on $PATH (typo in coc-settings.json servers/extension config); server binary version incompatible; server exits instantly due to bad args; firewall/permission blocking spawn on Windows.","solutions":["Fix the root launch failure: check :CocCommand workspace.showOutput for the original spawn/initialization error.","Verify the server executable exists and runs (`<server> --version` in a terminal).","Correct command/args in coc-settings.json or the extension's server options.","Create a new client instance (or :CocRestart) to reset StartFailed state and retry."],"exampleFix":"// before\n\"languageserver.rust\": { \"command\": \"rust-analyer\" }  // typo\n\n// after\n\"languageserver.rust\": { \"command\": \"rust-analyzer\" }","handlingStrategy":"try-catch","validationCode":"// preflight: verify the server command exists before start\nimport { execFileSync } from 'child_process'\nfunction serverExists(cmd: string): boolean {\n  try { execFileSync('which', [cmd]); return true } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await client.start()\n} catch (e) {\n  if (String(e).includes('Previous start failed')) {\n    // fix config, then rebuild a fresh client and retry\n    client = createNewClient()\n    await client.start()\n  }\n}","preventionTips":["Fix the original launch failure first: read workspace.showOutput for spawn errors.","Confirm the server binary is installed and on PATH (`which <server>`).","Validate command/args in coc-settings.json against the server's docs.","Rebuild the client instance after StartFailed — the state is sticky."],"tags":["language-client","server-start","lifecycle","lsp"],"backgroundTag":"previous-start-failed","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}