{"record":{"id":"e235aba75b761e6b","repo":"windmill-labs/windmill","slug":"network-error-could-not-connect-to-windmill-serve","errorCode":null,"errorMessage":"Network error: Could not connect to Windmill server at ${workspace.remote}","messagePattern":"Network error: Could not connect to Windmill server at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/core/auth.ts","lineNumber":80,"sourceCode":"  // Import resolveWorkspace to avoid circular dependency at module level\n  const { resolveWorkspace } = await import(\"./context.ts\");\n  const workspace = await resolveWorkspace(opts);\n\n  let token = await tryGetLoginInfo(opts);\n\n  if (!token) {\n    token = workspace.token;\n  }\n\n  setClient(token, workspace.remote.substring(0, workspace.remote.length - 1));\n\n  try {\n    return await fetchWhoami(workspace.workspaceId);\n  } catch (error) {\n    // Check for network errors and provide clearer messages\n    const errorMsg = error instanceof Error ? error.message : String(error);\n    if (errorMsg.includes('fetch') || errorMsg.includes('connection') || errorMsg.includes('ECONNREFUSED') || errorMsg.includes('refused')) {\n      throw new Error(`Network error: Could not connect to Windmill server at ${workspace.remote}`);\n    }\n\n    // If the user explicitly provided credentials via flags, fail immediately\n    // rather than falling back to interactive login — they expect their explicit\n    // credentials to work and should fix them if they don't.\n    if (opts.token || opts.baseUrl) {\n      const isApiError = error && typeof error === \"object\" &&\n        \"name\" in error && (error as { name: unknown }).name === \"ApiError\";\n      if (isApiError) {\n        const status = (error as { status?: number }).status;\n        const body = (error as { body?: unknown }).body;\n        let bodyStr = typeof body === \"object\" && body !== null\n          ? JSON.stringify(body)\n          : String(body ?? \"\").trim();\n        // Strip backend source-file refs like \"(flows.rs:1400)\" or\n        // \"@scopes.rs:509\" from the surfaced message — same pattern used in\n        // main.ts for ApiError display.\n        bodyStr = bodyStr.replace(/\\s*[@(]\\w+\\.rs:\\d+[:\\d]*\\)?/g, \"\");","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/core/auth.ts#L62-L98","documentation":"requireLogin's whoami probe failed with a network-level error (fetch could not reach the server at the workspace's remote URL): the instance is down, the URL is wrong, or DNS/TLS/proxy is failing — it is not an auth failure.","triggerScenarios":"Thrown at cli/src/core/auth.ts:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the instance URL with curl or a browser.","Check that the Windmill server is running and reachable from this machine.","Inspect proxies, VPN, and TLS certificates if the URL is correct."],"exampleFix":null,"handlingStrategy":"retry","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"}