langflow-ai/langflow · error · HTTPException

str(e)

Error message

str(e)

What it means

Catch-all raised when anything throws while queuing a flow build: creating the job entry or queue_service.start_job(job_id, task_coro). The original exception message is surfaced verbatim (str(e)) and logged with aexception. Typical roots are Redis connection failures in the job-queue service or errors building the task coroutine.

Source

Thrown at src/backend/base/langflow/api/build.py:237

        _, event_manager = queue_service.create_queue(job_id)
        task_coro = generate_flow_events(
            flow_id=flow_id,
            background_tasks=background_tasks,
            event_manager=event_manager,
            inputs=inputs,
            data=data,
            files=files,
            stop_component_id=stop_component_id,
            start_component_id=start_component_id,
            log_builds=log_builds,
            current_user=current_user,
            flow_name=flow_name,
            source_flow_id=source_flow_id,
        )
        queue_service.start_job(job_id, task_coro)
    except Exception as e:
        await logger.aexception("Failed to create queue and start task")
        raise HTTPException(status_code=500, detail=str(e)) from e
    return job_id


async def get_flow_events_response(
    *,
    job_id: str,
    queue_service: JobQueueService,
    event_delivery: EventDeliveryType,
):
    """Get events for a specific build job, either as a stream or single event."""
    try:
        main_queue, event_manager, event_task, _ = queue_service.get_queue_data(job_id)
        # Refresh the polling-watchdog heartbeat for any client-driven access
        # (polling and streaming both count as "client alive"). No-op for the
        # in-memory queue or when the watchdog is disabled.
        touch = getattr(queue_service, "touch_activity", None)
        if touch is not None:
            await touch(job_id)

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Check the backend log for the aexception entry — str(e) alone is often just 'Connection refused' style text.
  2. Verify LANGFLOW_REDIS_URL / cache config and that Redis is reachable from the backend container.
  3. For single-process dev runs, ensure the in-memory job queue service initialized (no Redis required).
  4. Retry after the backing service is healthy; the job was never started, so no orphan cleanup is needed.
Defensive patterns

Strategy: retry

Try / catch

try:
    job_id = await start_build(flow_id)
except HTTPError as e:
    if e.response.status_code == 500:
        # job never started; safe to retry once backing service is healthy
        await wait_for_queue_backend()
        job_id = await start_build(flow_id)
    else:
        raise

Prevention

When it happens

Trigger: POST /api/v1/build/{flow_id}/... (or the streaming build endpoint) while LANGFLOW_REDIS_URL points to an unreachable Redis in multi-worker mode; job-queue service not initialized; the task coroutine factory raising before the job starts.

Common situations: Redis down or credentials wrong after deploying with the queue/cache service backed by Redis; port-forwarded Redis in Docker not reachable; mixing memory queue with multiple workers.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/2f3725684907fffc. Report an issue: GitHub.