nautechsystems/nautilus_trader · error · anyhow::Error

No RPC URL provided for {name}. Set --rpc-url, INFURA_API_KE

Error message

No RPC URL provided for {name}. Set --rpc-url, INFURA_API_KEY, or RPC_HTTP_URL

What it means

Thrown by run_sync_dex when no HTTP RPC endpoint can be resolved for the chain from the --rpc-url argument, the Infura provider via INFURA_API_KEY, or the RPC_HTTP_URL environment variable. Syncing requires an RPC endpoint to read PoolCreated logs and cannot start without one.

Source

Thrown at crates/cli/src/blockchain/sync.rs:78

        anyhow::bail!(
            "DEX '{dex_type}' on chain '{}' cannot be synced: missing a PoolCreated parser for pool discovery.",
            chain.name
        );
    }

    let postgres_connect_options = get_postgres_connect_options(
        database.host,
        database.port,
        database.username,
        database.password,
        database.database,
    );
    // Get RPC HTTP URL: CLI arg, Infura provider, OR RPC_HTTP_URL env var
    let rpc_http_url = rpc_url
        .or_else(|| check_infura_rpc_provider(&chain.name))
        .or_else(|| std::env::var("RPC_HTTP_URL").ok())
        .ok_or_else(|| {
            anyhow::anyhow!(
                "No RPC URL provided for {name}. Set --rpc-url, INFURA_API_KEY, or RPC_HTTP_URL",
                name = chain.name
            )
        })?;

    // Mask potential API key in URL for logging (key is typically the last path segment)
    let masked_url = if let Some((base, key)) = rpc_http_url.rsplit_once('/') {
        if key.is_empty() {
            rpc_http_url.clone()
        } else {
            let masked_key = mask_api_key(key);
            format!("{base}/{masked_key}")
        }
    } else {
        // URL without path separator - mask entirely as it may contain credentials
        mask_api_key(&rpc_http_url)
    };

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass --rpc-url <https://...> explicitly for the chain.
  2. Export INFURA_API_KEY so the Infura provider lookup succeeds.
  3. Set RPC_HTTP_URL to a reachable HTTP(S) RPC endpoint.
  4. For systemd/docker, ensure the env var is passed into the service environment.

Example fix

// before
nautilusctl blockchain sync-dex --chain base --dex aerodrome
// error: no RPC URL
// after
nautilusctl blockchain sync-dex --chain base --dex aerodrome --rpc-url https://mainnet.base.org
Defensive patterns

Strategy: validation

Validate before calling

let has_rpc = rpc_url.is_some()
    || std::env::var("INFURA_API_KEY").is_ok()
    || std::env::var("RPC_HTTP_URL").is_ok();
if !has_rpc {
    eprintln!("provide --rpc-url, INFURA_API_KEY, or RPC_HTTP_URL for {}", chain.name);
    std::process::exit(2);
}

Prevention

When it happens

Trigger: run_blockchain_command -> run_sync_dex with rpc_url=None while check_infura_rpc_provider(chain.name) returns None and std::env::var("RPC_HTTP_URL") is unset or errors.

Common situations: Missing --rpc-url flag; INFURA_API_KEY not set in the environment (CI, containers, cron); chain not covered by the Infura provider mapping; RPC_HTTP_URL defined in a shell profile not loaded by the service manager.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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