nautechsystems/nautilus_trader · error
{method} redirect rejected
Error message
{method} redirect rejected What it means
This error is raised in `execute_execution_rpc_call` when the underlying HTTP client rejects a redirect response during a JSON-RPC execution-layer request. The lower-level `BlockchainRpcClientError::ClientError` contains "redirect response rejected" and is remapped to a clearer message naming the RPC method that was redirected.
Source
Thrown at crates/adapters/blockchain/src/rpc/http.rs:331
&self,
method: &'static str,
params: serde_json::Value,
) -> anyhow::Result<Option<T>> {
let request = serde_json::json!({
"jsonrpc": "2.0",
"id": 1,
"method": method,
"params": params,
});
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!("{method} redirect rejected")
}
_ => anyhow::anyhow!("{method} request failed"),
})?;
let parsed = serde_json::from_slice::<RpcNodeHttpResponse<T>>(bytes.as_ref())
.map_err(|_| anyhow::anyhow!("Failed to parse {method} response"))?;
if parsed.jsonrpc.is_none()
&& let (Some(code), Some(_message)) = (parsed.code, parsed.message)
{
anyhow::bail!("{method} RPC error {code}");
}
if let Some(error) = parsed.error {
anyhow::bail!("{method} RPC error {}", error.code);
}
Ok(parsed.result)View on GitHub (pinned to 18893faf8b)
Solutions
- Use the exact RPC endpoint URL that returns JSON-RPC directly (no redirect), e.g. include the full path
- Switch `http://` endpoint to `https://` if the server redirects to TLS
- Check load balancer/proxy rules for 3xx rewrites on the RPC path
- Confirm the port hosts the JSON-RPC service and not a web UI
Example fix
// before let url = "http://mainnet-node:8545"; // after (server redirects http->https and adds /rpc path) let url = "https://mainnet-node:8545/rpc";
Defensive patterns
Strategy: validation
Validate before calling
// verify the endpoint answers JSON-RPC directly with no redirect
// curl -sI -X POST $URL -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'
// assert status is 200, not 3xx Try / catch
match result {
Err(e) if e.to_string().ends_with("redirect rejected") => {
// fix endpoint URL (final destination, correct scheme/path) before retrying
}
other => other?,
} Prevention
- Configure the canonical, final URL of the RPC endpoint
- Prefer https:// endpoints to avoid scheme-redirects
- Verify with curl -I that no 3xx is returned
- Document the exact RPC path per environment
When it happens
Trigger: Any execution RPC method routed through `execute_execution_rpc_call` (chain_id, get_storage_at, get_code_with_block, get_transaction_count_*) when the configured node URL responds with an HTTP redirect (3xx) instead of a JSON-RPC response.
Common situations: Node URL missing a trailing path so the server redirects (e.g. `http://host:8545` redirecting to `http://host:8545/`), load balancer redirecting HTTP to HTTPS, or a wrong port hitting a web server instead of the RPC service.
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
- Failed to execute eth call RPC request: {e}
- {method} request failed
- eth_call redirect rejected
- debug_traceTransaction redirect rejected
- eth_call RPC error {code}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/c53a77e70a6a5a52.
Report an issue: GitHub.