{"record":{"id":"8588b21d5b0f4fc6","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-connect-to-otto-service","errorCode":null,"errorMessage":"Failed to connect to Otto service","messagePattern":"Failed to connect to Otto service","errorType":"http","errorClass":"HTTPException","httpStatus":503,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/otto/service.py","lineNumber":128,"sourceCode":"                    timeout=aiohttp.ClientTimeout(total=60),\n                ) as response:\n                    if response.status != 200:\n                        error_text = await response.text()\n                        logger.error(f\"Otto API error: {error_text}\")\n                        raise HTTPException(\n                            status_code=response.status,\n                            detail=f\"Otto API request failed: {error_text}\",\n                        )\n\n                    data = await response.json()\n                    logger.info(\n                        f\"Successfully received response from Otto API for user {user_id}\"\n                    )\n                    return ApiResponse(**data)\n\n        except aiohttp.ClientError as e:\n            logger.error(f\"Connection error to Otto API: {str(e)}\")\n            raise HTTPException(\n                status_code=503, detail=\"Failed to connect to Otto service\"\n            )\n        except asyncio.TimeoutError:\n            logger.error(\"Timeout error connecting to Otto API after 60 seconds\")\n            raise HTTPException(\n                status_code=504, detail=\"Request to Otto service timed out\"\n            )\n        except Exception as e:\n            logger.error(f\"Unexpected error in Otto API proxy: {str(e)}\")\n            raise HTTPException(\n                status_code=500, detail=\"Internal server error in Otto proxy\"\n            )\n","sourceCodeStart":110,"sourceCodeEnd":141,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/otto/service.py#L110-L141","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify OTTO_API_URL resolves and the port is open from inside the backend container (e.g. curl -v the URL).","Start the Otto service (docker compose up otto / redeploy) if it's down.","Fix the hostname/port in the URL to match the actual service address.","Check NetworkPolicy/firewall rules and TLS trust if connecting across environments."],"exampleFix":"# before\nOTTO_API_URL=https://otto.prod.internal:8080  # wrong port\n# after\nOTTO_API_URL=https://otto.prod.internal:443","handlingStrategy":"retry","validationCode":"// Pre-flight the upstream from the backend host\nconst reachable = await fetch(process.env.OTTO_API_URL, { method: 'HEAD' })\n  .then(() => true).catch(() => false);\nif (!reachable) throw new Error('Otto upstream unreachable');","typeGuard":null,"tryCatchPattern":"try { return await otto.ask(req); }\ncatch (e) {\n  if (e.status === 503 && e.detail === 'Failed to connect to Otto service') {\n    return await withBackoff(() => otto.ask(req), { tries: 3 });\n  }\n  throw e;\n}","preventionTips":["Health-check the Otto URL in container orchestration so bad instances restart.","Use stable internal service names/DNS for OTTO_API_URL; avoid hardcoded IPs.","Add the Otto host to egress allowlists in firewalls/NetworkPolicies."],"tags":["network","http-503","aiohttp","otto","connection-refused"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}