{"record":{"id":"d8cafc03e78df6be","repo":"windmill-labs/windmill","slug":"port-requested-is-already-in-use-holderhint-d8cafc","errorCode":null,"errorMessage":"Port ${requested} is already in use${holderHint}. Using port ${port} instead.","messagePattern":"Port (.+?) is already in use(.+?)\\. Using port (.+?) instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/utils/port-probe.ts","lineNumber":130,"sourceCode":" * at +20 to avoid silently scanning the whole 4xxx range. On shift, logs a\n * prominent warning naming the holder if we can find it.\n *\n * Returns the chosen port (== requested when it was already free).\n */\nexport async function resolveBindPort(\n  requested: number,\n  flagLabel: string,\n  log: { info: (msg: string) => void; warn: (msg: string) => void },\n): Promise<number> {\n  const MAX_SHIFT = 20;\n  for (let port = requested; port < requested + MAX_SHIFT; port++) {\n    if (await isPortFreeOnBothStacks(port)) {\n      if (port !== requested) {\n        const holder = findPortHolder(requested);\n        const holderHint = holder\n          ? ` (held by PID ${holder.pid} \\`${holder.command}\\`)`\n          : \"\";\n        log.warn(\n          `Port ${requested} is already in use${holderHint}. Using port ${port} instead.`,\n        );\n        log.info(\n          `If you need port ${requested} stable (e.g. a launch.json entry pinned to it), stop the holder and re-run with ${flagLabel} ${requested}.`,\n        );\n      }\n      return port;\n    }\n  }\n  throw new Error(\n    `Could not find a free port in the range ${requested}-${requested + MAX_SHIFT - 1}. Stop a holder or pass ${flagLabel} <other>.`,\n  );\n}\n\n/**\n * The host string we bind to. Explicit IPv4 — `localhost` resolves to\n * 127.0.0.1 first on every platform we care about, and binding both stacks\n * relies on platform-specific IPV6_V6ONLY behaviour we don't want to debug.","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/port-probe.ts#L112-L148","documentation":"Emitted by resolveBindPort: the requested port is occupied (holderHint names the holding process when identifiable), so the probe shifted up (max +20) and bound the first free port, which is reported. Only embedders hardcoding the original port are affected; the dev session otherwise works.","triggerScenarios":"Thrown at cli/src/utils/port-probe.ts:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Stop the process holding the port (named in holderHint)","Request a different port explicitly via the corresponding flag","Consume the reported port instead of assuming the requested one"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}