nautechsystems/nautilus_trader · error

eth_call redirect rejected

Error message

eth_call redirect rejected

What it means

In `call_result_at`, when the HTTP client reports `BlockchainRpcClientError::ClientError` containing "redirect response rejected" during an `eth_call`, this error is raised with the method name. It indicates the node endpoint attempted an HTTP redirect, which this client refuses for security/reliability.

Source

Thrown at crates/adapters/blockchain/src/rpc/http.rs:540

        });

        if let Some(from) = from {
            call["from"] = serde_json::json!(from);
        }
        let request = serde_json::json!({
            "jsonrpc": "2.0",
            "id": 1,
            "method": "eth_call",
            "params": [call, block_parameter(Some(block))],
        });
        let bytes = self
            .send_rpc_request(request, Some(EXECUTION_RPC_TIMEOUT_SECS))
            .await
            .map_err(|e| match e {
                BlockchainRpcClientError::ClientError(message)
                    if message.contains("redirect response rejected") =>
                {
                    anyhow::anyhow!("eth_call redirect rejected")
                }
                _ => anyhow::anyhow!("eth_call request failed"),
            })?;
        let parsed = serde_json::from_slice::<RpcNodeHttpResponse<String>>(bytes.as_ref())
            .map_err(|_| anyhow::anyhow!("Failed to parse eth_call response"))?;

        if parsed.jsonrpc.is_none()
            && let (Some(code), Some(message)) = (parsed.code, parsed.message)
        {
            if eth_call_error_is_revert(code, &message) {
                return Ok(RpcCallResult::Reverted);
            }
            anyhow::bail!("eth_call RPC error {code}");
        }

        if let Some(error) = parsed.error {
            if eth_call_error_is_revert(error.code, &error.message) {
                return Ok(RpcCallResult::Reverted);

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Update the RPC URL to the final destination (follow the redirect manually once and hardcode it)
  2. Use https:// if the node redirects http->https
  3. Check proxy/load balancer redirect rules on the eth_call route
  4. Confirm the URL path points at the JSON-RPC handler

Example fix

// before
let url = "http://node.internal:8545"; // redirects to /rpc
// after
let url = "http://node.internal:8545/rpc";
Defensive patterns

Strategy: validation

Validate before calling

// assert no redirect on the eth_call route before integration:
// curl -sI -X POST $URL -d '{"jsonrpc":"2.0","method":"eth_call","params":[{},"latest"],"id":1}'
// expect HTTP 200

Try / catch

match client.call_at(&tx, Some(block)).await {
    Err(e) if e.to_string().contains("redirect rejected") => {
        // resolve final URL (scheme/path) and reconfigure before retrying
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling `call_at` (eth_call) where the configured URL yields a 3xx redirect — wrong path, http->https redirect, or load balancer redirecting to a login/canonical URL.

Common situations: Endpoint URL missing the JSON-RPC path, TLS termination redirecting plain HTTP, or CDN redirecting to a regional canonical domain.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/3c7a969756c99cac. Report an issue: GitHub.