influxdata/influxdb · error · Error

failed to send request

Error message

failed to send {method} {url} request: {}

What it means

Error::RequestSend, raised when the client fails to dispatch an HTTP request at all — reqwest's send() returned an error before any response existed. The message embeds the HTTP method, URL, and reqwest_description of the source error, so it names exactly which request could not be sent and why (DNS, connect, TLS, timeout, redirect loop, etc.).

Solutions

  1. Read the source chain (eprintln!("{e:#}")) to see the exact reqwest cause (DNS vs connect vs TLS vs timeout)
  2. Verify the base URL host/port and that the InfluxDB 3 server is running and reachable (curl the /health endpoint)
  3. Fix DNS/network/firewall issues so the host resolves and the port is open
  4. For TLS errors, install/trust the correct CA or configure the client's certificate settings
  5. Add retry with exponential backoff for transient timeouts and connection resets

Example fix

// before
let client = Client::new("http://localhost:9999", ...); // wrong port
let resp = client.api_v3_query_sql(...).await?; // RequestSend: connection refused
// after
let client = Client::new("http://localhost:8181", ...);
let resp = client.api_v3_query_sql(...).await?;
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight connectivity check before issuing real requests
async fn reachable(base: &str) -> bool {
    reqwest::get(format!("{base}/health")).await.map(|r| r.status().is_success()).unwrap_or(false)
}

Type guard

fn is_request_send_error(e: &influxdb3_client::Error) -> bool {
    matches!(e, influxdb3_client::Error::RequestSend { .. })
}

Try / catch

match result {
    Err(influxdb3_client::Error::RequestSend { method, url, source }) => {
        log::warn!("send {method} {url} failed: {source:#}");
        if is_transient(&source) { backoff_and_retry().await } else { bail!(...) }
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling any Client request method when the target host is unreachable: DNS resolution failure, connection refused, TLS handshake/certificate failure, request timeout, too many redirects, or a request body error (e.g. bad content length).

Common situations: Wrong hostname/port in the base URL (connection refused); server not started yet; self-signed or expired certificates; private-cluster DNS not resolvable from the client environment; firewalls blocking egress.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/7b998303700323f6. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_client/src/lib.rs:64

    #[error("invalid UTF8 in response: {0}")]
    InvalidUtf8(#[from] FromUtf8Error),

    #[error("failed to parse JSON response: {}", reqwest_description(.0))]
    Json(#[source] reqwest::Error),

    #[error("failed to parse plaintext response: {}", reqwest_description(.0))]
    Text(#[source] reqwest::Error),

    #[error("server responded with error [{code}]: {message}")]
    ApiError {
        code: StatusCode,
        message: String,
        /// Machine-readable error code from JSON error responses, if present.
        error_code: Option<String>,
    },

    #[error("failed to send {method} {url} request: {}", reqwest_description(.source))]
    RequestSend {
        method: Method,
        url: String,
        #[source]
        source: reqwest::Error,
    },

    #[error("failed to build an http client: {}", reqwest_description(.0))]
    Builder(#[source] reqwest::Error),

    #[error("io error: {0}")]
    IO(#[from] std::io::Error),
}

/// Try to parse a JSON error response body with `error_code` and `message` fields.
/// Returns `(message, error_code)`. If JSON parsing fails, treats the body as plain text.
pub(crate) fn parse_error_body(body: &str) -> (String, Option<String>) {
    #[derive(serde::Deserialize)]

View on GitHub (pinned to 06200ef96b)