redis/node-redis · error · Error

Database ${name} not found in ${path}

Error message

Database ${name} not found in ${path}

What it means

loadREConnection() throws when the endpoints config JSON was loaded but contains no database entry under RE_DB_NAME (default 'standalone') and the fallback Object.values(data)[0] is also undefined — i.e., the config object is empty or has no usable database entries. The named lookup and the first-value fallback both failed.

Source

Thrown at packages/test-utils/lib/re-cluster.ts:54

/**
 * Resolves the managed Redis Enterprise database the suite should target, reading
 * the database named by RE_DB_NAME (default "standalone") from the endpoints config
 * at REDIS_ENDPOINTS_CONFIG_PATH - the same format consumed by the scenario tests.
 */
export function loadREConnection(): REConnection {
  if (cached) return cached;

  const path = process.env.REDIS_ENDPOINTS_CONFIG_PATH;
  if (!path) {
    throw new Error('REDIS_ENDPOINTS_CONFIG_PATH must be set when RE_CLUSTER=true');
  }

  const data = JSON.parse(readFileSync(path, 'utf-8')) as REDatabasesConfig;
  const name = process.env.RE_DB_NAME || 'standalone';
  const db = data[name] ?? Object.values(data)[0];
  if (!db) {
    throw new Error(`Database ${name} not found in ${path}`);
  }

  let host: string;
  let port: number;
  if (db.raw_endpoints && db.raw_endpoints.length > 0) {
    host = db.raw_endpoints[0].dns_name;
    port = db.raw_endpoints[0].port;
  } else if (db.endpoints && db.endpoints.length > 0) {
    const parsed = new URL(db.endpoints[0]);
    host = parsed.hostname;
    port = parsed.port ? Number(parsed.port) : parsed.protocol === 'rediss:' ? 6380 : 6379;
  } else {
    throw new Error(`No endpoints found for database ${name} in ${path}`);
  }

  cached = {
    host,
    port,

View on GitHub (pinned to 90fd0652bc)

Solutions

  1. Set RE_DB_NAME to a top-level key that exists in the endpoints JSON.
  2. Regenerate the endpoints config so it includes the expected database (default 'standalone') as a top-level entry.
  3. Inspect the JSON at REDIS_ENDPOINTS_CONFIG_PATH to confirm its top-level keys match the REDatabasesConfig shape (Record<string, REDatabaseConfig>).
  4. If the config nests databases under a wrapper, flatten it or update the loader to read the correct shape.

Example fix

// before — endpoints.json is {} or missing 'standalone'
{}

// after — top-level database entry present
{
  "standalone": {
    "tls": false,
    "raw_endpoints": [{ "dns_name": "re-host", "port": 12000 }]
  }
}
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs';
function dbExistsInConfig(path: string, name: string): boolean {
  const data = JSON.parse(readFileSync(path, 'utf-8')) as Record<string, unknown>;
  return Boolean(data[name] ?? Object.values(data)[0]);
}
// before loadREConnection():
if (!dbExistsInConfig(path, process.env.RE_DB_NAME || 'standalone')) {
  throw new Error(`Database '${process.env.RE_DB_NAME || 'standalone'}' missing from ${path}`);
}

Type guard

const isDatabaseConfig = (v: unknown): v is Record<string, unknown> =>
  typeof v === 'object' && v !== null && !Array.isArray(v);

Prevention

When it happens

Trigger: REDIS_ENDPOINTS_CONFIG_PATH points at a valid JSON file that is {} or lacks the RE_DB_NAME key and has no other top-level database objects; or the databases are nested under a key the loader does not expect (schema drift).

Common situations: Empty or stub endpoints config generated by the pipeline; RE_DB_NAME set to a name not present in the file; config schema changed so databases live under a wrapper key; config written for a different environment.

Related errors


AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11). Data as JSON: /api/errors/63872d78cbc3a51d. Report an issue: GitHub.