Significant-Gravitas/AutoGPT · error · HTTPException

Failed to connect to Otto service

Error message

Failed to connect to Otto service

What it means

Raised by OttoService.ask when aiohttp raises a ClientError while connecting or exchanging with the Otto API — DNS failure, connection refused, TLS errors, or a broken connection. The client gets a 503 indicating the proxy could not reach its upstream.

Source

Thrown at autogpt_platform/backend/backend/api/features/otto/service.py:128

                    timeout=aiohttp.ClientTimeout(total=60),
                ) as response:
                    if response.status != 200:
                        error_text = await response.text()
                        logger.error(f"Otto API error: {error_text}")
                        raise HTTPException(
                            status_code=response.status,
                            detail=f"Otto API request failed: {error_text}",
                        )

                    data = await response.json()
                    logger.info(
                        f"Successfully received response from Otto API for user {user_id}"
                    )
                    return ApiResponse(**data)

        except aiohttp.ClientError as e:
            logger.error(f"Connection error to Otto API: {str(e)}")
            raise HTTPException(
                status_code=503, detail="Failed to connect to Otto service"
            )
        except asyncio.TimeoutError:
            logger.error("Timeout error connecting to Otto API after 60 seconds")
            raise HTTPException(
                status_code=504, detail="Request to Otto service timed out"
            )
        except Exception as e:
            logger.error(f"Unexpected error in Otto API proxy: {str(e)}")
            raise HTTPException(
                status_code=500, detail="Internal server error in Otto proxy"
            )

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Verify OTTO_API_URL resolves and the port is open from inside the backend container (e.g. curl -v the URL).
  2. Start the Otto service (docker compose up otto / redeploy) if it's down.
  3. Fix the hostname/port in the URL to match the actual service address.
  4. Check NetworkPolicy/firewall rules and TLS trust if connecting across environments.

Example fix

# before
OTTO_API_URL=https://otto.prod.internal:8080  # wrong port
# after
OTTO_API_URL=https://otto.prod.internal:443
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight the upstream from the backend host
const reachable = await fetch(process.env.OTTO_API_URL, { method: 'HEAD' })
  .then(() => true).catch(() => false);
if (!reachable) throw new Error('Otto upstream unreachable');

Try / catch

try { return await otto.ask(req); }
catch (e) {
  if (e.status === 503 && e.detail === 'Failed to connect to Otto service') {
    return await withBackoff(() => otto.ask(req), { tries: 3 });
  }
  throw e;
}

Prevention

When it happens

Trigger: OTTO_API_URL points at a hostname that doesn't resolve, a service that isn't listening (connection refused), a TLS cert mismatch, or the connection resets mid-request. Any chat request in this state fails immediately with 503.

Common situations: Otto container not started in docker-compose; wrong service name/port in OTTO_API_URL in a service-mesh/K8s environment; firewall/NetworkPolicy blocking egress; TLS certificate rotated and now invalid.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/8588b21d5b0f4fc6. Report an issue: GitHub.