influxdata/influxdb · error · Error::DatabaseNotFound
Database not found
Error message
Database {0} not found What it means
Raised by the v1 query API when the database name supplied by the caller (path, parameter, or query) does not correspond to any database known to the server. It is a lookup/validation guard at request handling time, not an IO error — the request is rejected before any query executes. The at-fault input is the database name in the error payload; typical causes are typos, deleted databases, or querying the wrong server.
Solutions
- Verify the exact database name in the error message and correct the `db` parameter.
- List available databases (e.g. SHOW DATABASES or the catalog API) and pick the right one.
- Create the database if it should exist before querying it.
- Fix environment-specific client configuration pointing at the wrong database.
Example fix
// before GET /query?db=prod-metrics&q=SELECT+*+FROM+cpu // after GET /query?db=prod_metrics&q=SELECT+*+FROM+cpu
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_DBS = new Set(['prod_metrics', 'staging_metrics']);
function assertDbExists(db) {
if (!KNOWN_DBS.has(db)) throw new Error(`database "${db}" does not exist`);
} Try / catch
try {
await queryV1({ db, q });
} catch (e) {
const m = /^Database (.+) not found$/.exec(e.message);
if (m) console.error(`check db name: ${m[1]}`);
else throw e;
} Prevention
- Fetch the database list at client startup and validate `db` against it.
- Use environment-scoped config files instead of hardcoding db names.
- Alert on DatabaseNotFound to catch provisioning drift early.
When it happens
Trigger: GET/POST to the v1 /query endpoint with a `db` parameter (or query-qualified database) naming a database that has never been created or has been deleted.
Common situations: Typos in the `db` parameter; pointing clients at environments where the database was never provisioned; databases deleted by retention/lifecycle jobs; staging-vs-production naming drift.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- database not found
- database not found
- datafusion error
- must specify a 'db' parameter, or provide the database in…
- provided a database in both the parameters
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/3ff8d528f93b201e.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_v1_query_api/src/error.rs:83
from your request"
)]
InfluxqlDatabaseMismatch { param_db: String, query_db: String },
#[error(
"provided a retention policy in both the parameters ({param_rp}) and \
query string ({query_rp}) that do not match, if providing a query \
that specifies the retention_policy, you can omit the 'rp' parameter \
from your request"
)]
InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },
#[error("error reading field from body: {name} -- {error}")]
FieldRead { name: &'static str, error: String },
#[error("Cannot retrieve database: {0}")]
Database(DataFusionError),
#[error("Database {0} not found")]
DatabaseNotFound(String),
#[error("v1 query API error: {0}")]
V1Query(#[from] QueryError),
}
#[derive(Debug, Clone)]
pub enum HttpError {
NotFound(String),
Unauthorized(String),
Invalid(String),
InternalError(String),
}
impl From<Error> for HttpError {
fn from(e: Error) -> Self {
use Error::*;
use HttpError::*;View on GitHub (pinned to 06200ef96b)