influxdata/influxdb · error · Error

missing query parameters 'db' and 'q'

Error message

missing query parameters 'db' and 'q'

What it means

This error indicates a query request was missing both required query parameters: `db` (the target database) and `q` (the query text). The server validates both before executing anything and reports exactly which parameters were absent via this message.

Solutions

  1. Include both parameters: ?db=mydb&q=SELECT%20*%20FROM%20measurement.
  2. URL-encode the SQL in `q` (spaces, quotes, operators) so the query string parses correctly.
  3. If POSTing, send parameters as application/x-www-form-urlencoded or in the query string, per the API contract.
  4. Check the endpoint path matches your server version's query API.

Example fix

// before
let url = "http://localhost:8181/query";
// after
let url = "http://localhost:8181/query?db=metrics&q=SELECT%20*%20FROM%20cpu";
Defensive patterns

Strategy: validation

Validate before calling

fn build_query_url(base: &str, db: &str, q: &str) -> String {
    assert!(!db.is_empty(), "db is required");
    assert!(!q.is_empty(), "q is required");
    format!("{base}?db={}&q={}", urlencode(db), urlencode(q))
}

Prevention

When it happens

Trigger: GET/POST to the query endpoint (/query or /api/v3/query_sql legacy surface) with neither `db` nor `q` in the query string or form body — e.g. an empty GET request or a POST with the wrong content type so parameters were not parsed.

Common situations: Opening the query endpoint directly in a browser with no parameters; sending parameters as a JSON body to an endpoint that only reads the URL query string; URL built by concatenation that dropped everything after '?'.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at influxdb3_server/src/http.rs:268

    /// The provided authorization is not sufficient to perform the request.
    #[error("access denied")]
    Forbidden,

    /// The HTTP request method is not supported for this resource
    #[error("unsupported method")]
    UnsupportedMethod,

    /// Hyper serving error
    #[error("error serving http: {0}")]
    ServingHttp(#[from] hyper::Error),

    /// Missing parameters for query
    #[error("missing query parameters 'db'")]
    MissingDeleteDatabaseParams,

    /// Missing parameters for query
    #[error("missing query parameters 'db' and 'q'")]
    MissingQueryParams,

    /// Missing the `q` parameter in the v1 /query API
    #[error("missing query parameter 'q'")]
    MissingQueryV1Params,

    /// MIssing parameters for write
    #[error("missing query parameter 'db'")]
    MissingWriteParams,

    #[error("the mime type specified was not valid UTF8: {0}")]
    NonUtf8MimeType(#[from] FromUtf8Error),

    /// Serde decode error
    #[error("serde error: {0}")]
    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),

    /// Arrow error

View on GitHub (pinned to 06200ef96b)