neoclide/coc.nvim · error · Error

Starting server failed

Error message

Starting server failed

What it means

Thrown by $start() after awaiting _start() when activeConnection() still returns undefined — i.e., the client reported a successful start sequence but no active connection materialized. This indicates the start promise resolved without the connection being registered (internal race or silent server failure).

Source

Thrown at src/language-client/client.ts:1068

  public start(): Promise<void> & Disposable {
    let p: any = this._start()
    p.dispose = () => {
      if (this.needsStop()) {
        void this.stop()
      }
    }
    return p
  }

  private async $start(): Promise<Connection> {
    if (this.$state === ClientState.StartFailed) {
      throw new Error(`Previous start failed. Can't restart server.`)
    }
    await this._start()
    const connection = this.activeConnection()
    if (connection === undefined) {
      throw new Error(`Starting server failed`)
    }
    return connection
  }

  private handleConnectionEvents(connection: Connection) {
    connection.onNotification(LogMessageNotification.type, message => {
      switch (message.type) {
        case MessageType.Error:
          this.error(message.message)
          break
        case MessageType.Warning:
          this.warn(message.message)
          break
        case MessageType.Info:
          this.info(message.message)
          break
        case MessageType.Debug:
          this.debug(message.message)

View on GitHub (pinned to 50e974d969)

Solutions

  1. Check :CocCommand workspace.showOutput and server stderr for crash output.
  2. Run the server binary manually to confirm it stays alive and speaks LSP over stdio.
  3. Retry with :CocRestart — transient races usually succeed on a second start.
  4. If using a custom transport (socket/pipe), verify address/port and connection setup.
  5. Update the language server and coc.nvim; report if consistently reproducible.
Defensive patterns

Strategy: retry

Try / catch

async function startWithRetry(client, attempts = 2) {
  for (let i = 0; i < attempts; i++) {
    try {
      return await client.start()
    } catch (e) {
      if (i === attempts - 1 || !String(e).includes('Starting server failed')) throw e
    }
  }
}

Prevention

When it happens

Trigger: Server process spawned but exited before completing initialization while _start still resolved; connection closed asynchronously between _start resolution and activeConnection() read; custom server transports (e.g. child process, socket, worker) failing to attach a connection; timing issue in doInitialize or connection handlers.

Common situations: Flaky server binaries that die immediately after spawn; stdio server crashing on startup output; misconfigured socket/piped transports in coc-settings.json; environment issues (missing libraries causing delayed crash).

Related errors


AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31). Data as JSON: /api/errors/7ec8d93cfa36c6ec. Report an issue: GitHub.