influxdata/influxdb · error · Error

database not found

Error message

database not found {db_name}

What it means

The DatabaseNotFound variant of influxdb3_server::Error: a query or write referenced a database name that does not exist in the catalog. The server cannot resolve the requested database, so the operation is rejected with the offending db_name in the message.

Solutions

  1. Verify the exact database name with the server's catalog (e.g. SHOW DATABASES / the list-databases API)
  2. Create the database first (POST /api/v3/configure/database) before querying/writing to it
  3. Confirm the client is pointed at the intended server instance and organization

Example fix

// before
client.query_sql(db="sensors-prod", "SELECT * FROM cpu").await?; // db may not exist
// after
let dbs = client.list_databases().await?;
anyhow::ensure!(dbs.contains(&"sensors-prod".into()), "create the database first");
client.query_sql("sensors-prod", "SELECT * FROM cpu").await?;
Defensive patterns

Strategy: validation

Validate before calling

let existing: Vec<String> = client.list_databases().await?;
if !existing.contains(&db_name.to_string()) {
    return Err(format!("database '{db_name}' does not exist; create it first"));
}

Try / catch

match err {
    ServerError::DatabaseNotFound { db_name } => {
        eprintln!("db '{db_name}' missing — creating it and retrying");
        client.create_database(&db_name).await?;
    }
    _ => return Err(err),
}

Prevention

When it happens

Trigger: Querying (POST /api/v3/query, SQL or InfluxQL) with a database parameter that was never created; writing to a database before creating it when auto-creation is disabled; referencing a database that was deleted or that belongs to a different org/instance.

Common situations: Typo in the db name in a client config; environment mismatch (querying a staging database on a production server); database dropped between writes and queries; connection pointed at the wrong InfluxDB instance or port.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at influxdb3_server/src/lib.rs:69

use trace_http::metrics::{MetricFamily, RequestMetrics};
use trace_http::tower::{ServiceProtocol, TraceLayer};
use unified_service::{RemoteAddrLayer, UnifiedService};

pub const PRODUCT_NAME: &str = "InfluxDB 3 Core";
pub const INFLUXDB3_BUILD: &str = "Core";

/// Version string combining the product name, [`influxdb3_process::INFLUXDB3_VERSION`], and [`influxdb3_process::INFLUXDB3_GIT_HASH`].
pub static VERSION_STRING: LazyLock<String> = LazyLock::new(|| build_version_string(PRODUCT_NAME));

#[derive(Debug, Error)]
pub enum Error {
    #[error("hyper error: {0}")]
    Hyper(#[from] hyper::Error),

    #[error("http error: {0}")]
    Http(#[from] Box<http::Error>),

    #[error("database not found {db_name}")]
    DatabaseNotFound { db_name: String },

    #[error("datafusion error: {0}")]
    DataFusion(#[from] datafusion::error::DataFusionError),

    #[error("influxdb3_write error: {0}")]
    InfluxDB3Write(#[from] influxdb3_write::Error),

    #[error("from hex error: {0}")]
    FromHex(#[from] hex::FromHexError),

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

    #[error("tls config error: {0}")]
    TlsConfig(String),

    #[error("rustls error: {0}")]

View on GitHub (pinned to 06200ef96b)