influxdata/influxdb · error · Error

missing query parameter 'db'

Error message

missing query parameter 'db'

What it means

This error is returned by the HTTP write API (influxdb3_server/src/http.rs) when a write request arrives without the required 'db' query parameter. The server maps it to a 400 Bad Request response so the client knows the request was malformed before it reached the write buffer.

Solutions

  1. Add the db query parameter to the write URL: ?db=mydb
  2. Confirm you are using the correct endpoint for your InfluxDB 3 version (v1 /write?db= vs v2 /api/v2/write?org=&bucket=)
  3. Check that any reverse proxy/load balancer is not stripping the query string
  4. Log the full request URL on failure to verify the parameter is present

Example fix

// before
curl -XPOST 'http://localhost:8181/write' --data-binary 'cpu,host=a usage=90'
// after
curl -XPOST 'http://localhost:8181/write?db=mydb' --data-binary 'cpu,host=a usage=90'
Defensive patterns

Strategy: validation

Validate before calling

if (!url.includes("db=")) { throw new Error("write URL must include ?db=<database>"); }
const db = new URL(url).searchParams.get("db");
if (!db) throw new Error("missing 'db' query parameter");

Type guard

function hasDbParam(url) { return new URLSearchParams(url.split("?")[1] ?? "").has("db"); }

Try / catch

try {
  await res = fetch(writeUrl);
  if (res.status === 400 && (await res.text()).includes("missing query parameter 'db'")) {
    // fix URL and retry once with db appended
  }
} catch (e) { /* network failure, not this error */ }

Prevention

When it happens

Trigger: POSTing to the /write or /api/v2/write endpoint without ?db=<database-name> in the URL, e.g. curl -XPOST 'http://host:8181/write' --data-binary 'm v=1'.

Common situations: Migrating from v1 setups where the database came from basic-auth or config; building the URL by string concatenation and dropping the query string; proxies or SDKs stripping unknown query params.

Understand the failure class

Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at influxdb3_server/src/http.rs:276

    /// 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
    #[error("arrow error: {0}")]
    Arrow(#[from] arrow::error::ArrowError),

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

    /// WriteBuffer error

View on GitHub (pinned to 06200ef96b)