moeru-ai/airi · error · Error
Cannot connect to ComfyUI at ${this.serverUrl}: ${e.message}
Error message
Cannot connect to ComfyUI at ${this.serverUrl}: ${e.message} What it means
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.
Source
Thrown at apps/stage-tamagotchi/src/main/services/airi/widgets/providers/comfyui.ts:143
resolvedPrompt = this.replacePlaceholders(resolvedPrompt, replacements)
}
log.log(`[ComfyUI] Resolved prompt for ${jobId}:`, JSON.stringify(resolvedPrompt, null, 2))
// 2. POST /prompt to queue the workflow
this.updateStatus(jobId, { status: 'running', actionLabel: 'Queuing in ComfyUI...' })
let queueResp: Response
try {
queueResp = await this.fetchWithTimeout(`${this.serverUrl}/prompt`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ prompt: resolvedPrompt }),
}, 15000)
}
catch (e: any) {
throw new Error(`Cannot connect to ComfyUI at ${this.serverUrl}: ${e.message}`)
}
if (!queueResp.ok) {
const errorBody = await queueResp.text()
throw new Error(`Workflow error: ${errorBody.slice(0, 200)}`)
}
const queueData = await queueResp.json()
const promptId = queueData.prompt_id
if (!promptId) {
throw new Error('ComfyUI returned no prompt_id')
}
log.log(`[ComfyUI] Queued prompt ${promptId} for job ${jobId}`)
this.updateStatus(jobId, { status: 'running', actionLabel: 'Generating...' })
// 3. Poll /history/{prompt_id} until completion
let historyDone = falseView on GitHub (pinned to 27111382b4)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate reachability before queuing a prompt
async function comfyUIAlive(serverUrl: string): Promise<boolean> {
try {
const r = await fetch(`${serverUrl}/system_stats`, { signal: AbortSignal.timeout(5000) })
return r.ok
} catch {
return false
}
} Try / catch
try {
return await provider.generate(request)
} catch (e) {
if (/Cannot connect to ComfyUI/.test(errorMessageFrom(e) ?? '')) {
// surface a reconnect prompt to the user; do not auto-loop
throw new Error('ComfyUI unreachable. Check it is running and the URL is correct.')
}
throw e
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- ComfyUI disconnected during polling: ${e.message}
- HTTP ${resp.status}
- ComfyUI upload failed: ${error}
- Failed to fetch image: ${response.statusText}
- Workflow error: ${errorBody.slice(0, 200)}
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/4d67ec77119ab1f4.
Report an issue: GitHub.