{"record":{"id":"4d67ec77119ab1f4","repo":"moeru-ai/airi","slug":"cannot-connect-to-comfyui-at-this-serverurl","errorCode":null,"errorMessage":"Cannot connect to ComfyUI at ${this.serverUrl}: ${e.message}","messagePattern":"Cannot connect to ComfyUI at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/stage-tamagotchi/src/main/services/airi/widgets/providers/comfyui.ts","lineNumber":143,"sourceCode":"\n        resolvedPrompt = this.replacePlaceholders(resolvedPrompt, replacements)\n      }\n\n      log.log(`[ComfyUI] Resolved prompt for ${jobId}:`, JSON.stringify(resolvedPrompt, null, 2))\n\n      // 2. POST /prompt to queue the workflow\n      this.updateStatus(jobId, { status: 'running', actionLabel: 'Queuing in ComfyUI...' })\n\n      let queueResp: Response\n      try {\n        queueResp = await this.fetchWithTimeout(`${this.serverUrl}/prompt`, {\n          method: 'POST',\n          headers: { 'Content-Type': 'application/json' },\n          body: JSON.stringify({ prompt: resolvedPrompt }),\n        }, 15000)\n      }\n      catch (e: any) {\n        throw new Error(`Cannot connect to ComfyUI at ${this.serverUrl}: ${e.message}`)\n      }\n\n      if (!queueResp.ok) {\n        const errorBody = await queueResp.text()\n        throw new Error(`Workflow error: ${errorBody.slice(0, 200)}`)\n      }\n\n      const queueData = await queueResp.json()\n      const promptId = queueData.prompt_id\n      if (!promptId) {\n        throw new Error('ComfyUI returned no prompt_id')\n      }\n\n      log.log(`[ComfyUI] Queued prompt ${promptId} for job ${jobId}`)\n      this.updateStatus(jobId, { status: 'running', actionLabel: 'Generating...' })\n\n      // 3. Poll /history/{prompt_id} until completion\n      let historyDone = false","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/apps/stage-tamagotchi/src/main/services/airi/widgets/providers/comfyui.ts#L125-L161","documentation":"Thrown by the ComfyUI provider when fetchWithTimeout to <serverUrl>/prompt throws (network-level failure) rather than returning a response. The catch wraps any thrown error and re-throws with the server URL and the underlying error message for diagnosability.","triggerScenarios":"POST to /prompt cannot establish a connection — ComfyUI server is down, wrong host/port, DNS failure, TLS error, connection refused, or the 15-second fetchWithTimeout expired before a response (server too slow to even accept the connection).","commonSituations":"ComfyUI process crashed or was stopped; serverUrl is wrong or stale (e.g. localhost vs LAN IP); firewall blocks the port; the 15s timeout is too short for a heavily loaded ComfyUI; VPN/network changed after config.","solutions":["Confirm ComfyUI is running and reachable at this.serverUrl (curl the /system_stats endpoint).","Correct the serverUrl in the artistry/ComfyUI config to the actual host:port.","Check for firewall/network/VPN blocking the port.","If the server is just slow, raise the fetchWithTimeout (currently 15000ms) for the /prompt call."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate reachability before queuing a prompt\nasync function comfyUIAlive(serverUrl: string): Promise<boolean> {\n  try {\n    const r = await fetch(`${serverUrl}/system_stats`, { signal: AbortSignal.timeout(5000) })\n    return r.ok\n  } catch {\n    return false\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await provider.generate(request)\n} catch (e) {\n  if (/Cannot connect to ComfyUI/.test(errorMessageFrom(e) ?? '')) {\n    // surface a reconnect prompt to the user; do not auto-loop\n    throw new Error('ComfyUI unreachable. Check it is running and the URL is correct.')\n  }\n  throw e\n}","preventionTips":["Verify ComfyUI is running before submitting jobs.","Keep serverUrl stable (avoid localhost vs LAN IP drift).","Raise the 15s /prompt fetchWithTimeout if ComfyUI is slow to accept connections under load."],"tags":["comfyui","network","connection","artistry"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}