infiniflow/ragflow · error · RuntimeError

HTTP request failed: {str(e)}

Error message

HTTP request failed: {str(e)}

What it means

Raised by SelfManagedProvider.execute_code() when the requests.post to {endpoint}/run fails with a requests.RequestException other than Timeout — i.e. the HTTP request never completed. Causes include DNS resolution failure, connection refused, SSL/TLS errors, and connection resets. The original exception string is embedded (RuntimeError wrapping str(e)).

Source

Thrown at agent/sandbox/providers/self_managed.py:181

                metadata={
                    "status": result.get("status"),
                    "time_used_ms": result.get("time_used_ms"),
                    "memory_used_kb": result.get("memory_used_kb"),
                    "detail": result.get("detail"),
                    "instance_id": instance_id,
                    "artifacts": result.get("artifacts", []),
                    "result_present": structured_result.get("present", False),
                    "result_value": structured_result.get("value"),
                    "result_type": structured_result.get("type"),
                },
            )

        except requests.Timeout:
            execution_time = time.time() - start_time
            raise TimeoutError(f"Execution timed out after {exec_timeout} seconds")

        except requests.RequestException as e:
            raise RuntimeError(f"HTTP request failed: {str(e)}")

    def destroy_instance(self, instance_id: str) -> bool:
        """
        Destroy a sandbox instance.

        Note: For self-managed provider, instances are returned to the
        internal pool automatically by executor_manager after execution.
        This is a no-op for tracking purposes.

        Args:
            instance_id: ID of the instance to destroy

        Returns:
            True (always succeeds for self-managed)
        """
        # The executor_manager manages container lifecycle internally
        # Container is returned to pool after execution
        return True

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Verify the sandbox service is running and the endpoint URL/host/port in the provider config is correct (curl it from the same host/network).
  2. For SSL errors, fix the scheme (http vs https) or provide proper certificates.
  3. Add a health-check gate before execution (ping the service's health route) and fail with a clearer message.
  4. Retry with backoff only for transient resets; persistent failure means config or service state, not load.

Example fix

# before
provider.initialize({"endpoint": "https://sandbox-svc:8080"})  # SSL/wrong scheme

# after
provider.initialize({"endpoint": "http://sandbox-svc:8080"})
Defensive patterns

Strategy: try-catch

Validate before calling

import socket
from urllib.parse import urlparse
u = urlparse(endpoint)
with socket.create_connection((u.hostname, u.port or 80), timeout=5):
    pass  # endpoint reachable before executing

Try / catch

try:
    result = provider.execute_code(instance_id, code, "python")
except RuntimeError as e:
    if "HTTP request failed" in str(e):
        # transport-level: check service up / DNS / scheme; not retryable until fixed
        raise SandboxUnreachable(str(e)) from e
    raise

Prevention

When it happens

Trigger: Endpoint host unresolvable (typo in config); sandbox service not listening / wrong port (Connection refused); https endpoint with self-signed or mismatched cert (SSLError); firewall or proxy resetting the connection; service crashed between health check and call.

Common situations: Sandbox service container not started or still booting; endpoint configured as https:// against an http-only listener; DNS entry missing in the compose network; the requests library not installed per environment (import-level, different failure) — here strictly transport-level.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/8ca91e95424f08e4. Report an issue: GitHub.