{"record":{"id":"0c0de89477ef2e99","repo":"paperclipai/paperclip","slug":"runtime-service-could-not-bind-allocated-port-po","errorCode":null,"errorMessage":"Runtime service could not bind allocated port ${port}","messagePattern":"Runtime service could not bind allocated port (.+?)","errorType":"exception","errorClass":"RuntimeServicePortBindCollision","httpStatus":null,"severity":"error","filePath":"server/src/services/workspace-runtime.ts","lineNumber":4819,"sourceCode":"  throw new Error(`Readiness check failed for ${readinessUrl}: ${lastError}`);\n}\n\nasync function waitForAllocatedPortBind(input: {\n  service: Record<string, unknown>;\n  port: number;\n  child: ChildProcess;\n}) {\n  const deadline = Date.now() + resolveWorkspaceRuntimeReadinessTimeoutSec(input.service) * 1000;\n  while (Date.now() < deadline) {\n    if (input.child.exitCode !== null || input.child.signalCode !== null) {\n      throw new Error(\"service process exited before binding its allocated port\");\n    }\n\n    const ownerPid = await readLocalServicePortOwner(input.port);\n    if (ownerPid) {\n      const childPid = input.child.pid ?? null;\n      if (!childPid || !(await isLocalServiceProcessOwnedBy(ownerPid, childPid))) {\n        throw new RuntimeServicePortBindCollision(input.port);\n      }\n      // Require the same launched process group to retain ownership across a stability delay.\n      // Cwd matching alone is insufficient because sibling services can share a workspace.\n      await delay(250);\n      if (input.child.exitCode !== null || input.child.signalCode !== null) {\n        throw new Error(\"service process exited after losing its allocated port\");\n      }\n      const stableOwnerPid = await readLocalServicePortOwner(input.port);\n      if (!stableOwnerPid || !(await isLocalServiceProcessOwnedBy(stableOwnerPid, childPid))) {\n        throw new RuntimeServicePortBindCollision(input.port);\n      }\n      return;\n    }\n\n    // A present listener proves only that some listener appeared. If listener ownership cannot\n    // be attributed to this child after a stability delay, retry instead of accepting a sibling.\n    // The presence read never binds the port, so it cannot steal the port from the child.\n    if (await hasLoopbackPortListener(input.port)) {","sourceCodeStart":4801,"sourceCodeEnd":4837,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/services/workspace-runtime.ts#L4801-L4837","documentation":"The service process is alive but has not bound its allocated port before the readiness timeout expired. The service is hanging or listening elsewhere, so the managed runtime service start is failed.","triggerScenarios":"Thrown at server/src/services/workspace-runtime.ts:4666 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the runtime service listen on the allocated port, or configure a different free port.","Check that nothing else grabbed the port between allocation and bind, then retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}