{"record":{"id":"c365cab1b032f741","repo":"chroma-core/chroma","slug":"could-not-connect-to-tenant-tenant-are-you-sur","errorCode":null,"errorMessage":"Could not connect to tenant ${tenant}. Are you sure it exists? Underlying error:\n${error}","messagePattern":"Could not connect to tenant (.+?)\\. Are you sure it exists\\? Underlying error:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/utils.ts","lineNumber":69,"sourceCode":" * @param {string} moduleName - Specifies the module to import.\n * @returns {Promise<any>} Returns a Promise that resolves to the imported module.\n */\nexport async function importOptionalModule(moduleName: string) {\n  return Function(`return import(\"${moduleName}\")`)();\n}\n\nexport async function validateTenantDatabase(\n  adminClient: AdminClient,\n  tenant: string,\n  database: string,\n): Promise<void> {\n  try {\n    await adminClient.getTenant({ name: tenant });\n  } catch (error) {\n    if (error instanceof ChromaConnectionError) {\n      throw error;\n    }\n    throw new Error(\n      `Could not connect to tenant ${tenant}. Are you sure it exists? Underlying error:\n${error}`,\n    );\n  }\n\n  try {\n    await adminClient.getDatabase({ name: database, tenantName: tenant });\n  } catch (error) {\n    if (error instanceof ChromaConnectionError) {\n      throw error;\n    }\n    throw new Error(\n      `Could not connect to database ${database} for tenant ${tenant}. Are you sure it exists? Underlying error:\n${error}`,\n    );\n  }\n}\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/utils.ts#L51-L87","documentation":"validateTenantDatabase() calls AdminClient.getTenant({ name: tenant }); if it throws anything that is NOT a ChromaConnectionError, the error is wrapped with this message. Because connection-level failures are rethrown untouched, seeing this message means the server WAS reached and answered — almost always that the tenant does not exist (404) on that server.","triggerScenarios":"new ChromaClient({ tenant: 'acme', database: 'db' }) (validated on first init()/operation), adminClient.setTenant({ tenant: 'acme', database: 'db' }), or adminClient.setDatabase() where tenant 'acme' was never created with adminClient.createTenant({ name: 'acme' }) — or exists on a different server (wrong host/port).","commonSituations":"First use of multi-tenant mode assuming tenants auto-create; typo/case difference in the tenant name; connecting to default localhost:8000 in prod while the tenant lives on another instance; load-balanced Chroma instances with divergent state.","solutions":["Create the tenant first: await adminClient.createTenant({ name: tenant }) — creating an existing tenant is not an error, so this is safe to run idempotently.","List tenants to verify the exact name: (await adminClient.listTenants()).forEach(t => console.log(t.name)).","Confirm the client points at the server where the tenant was created (path/host/port, auth provider).","Check for typos, case sensitivity, and trailing whitespace in the tenant string."],"exampleFix":"// before\nconst client = new ChromaClient({ tenant: \"acme\", database: \"prod-db\" });\nawait client.listCollections(); // init() -> getTenant 404 -> throws\n\n// after\nconst admin = new AdminClient({ path: \"http://localhost:8000\" });\nawait admin.createTenant({ name: \"acme\" });\nawait admin.createDatabase({ name: \"prod-db\", tenantName: \"acme\" });\nconst client = new ChromaClient({ tenant: \"acme\", database: \"prod-db\" });","handlingStrategy":"validation","validationCode":"// Ensure the tenant exists before pointing a client at it\nconst ensureTenant = async (admin: AdminClient, tenant: string) => {\n  try {\n    await admin.getTenant({ name: tenant });\n  } catch (e) {\n    if (e instanceof ChromaConnectionError) throw e; // server unreachable — different problem\n    await admin.createTenant({ name: tenant }); // 404 -> create idempotently\n  }\n};\nawait ensureTenant(admin, \"acme\");","typeGuard":null,"tryCatchPattern":"try {\n  await client.listCollections(); // triggers init()/tenant validation\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.startsWith(\"Could not connect to tenant\")) {\n    throw new Error(`Tenant not found — run adminClient.createTenant({ name: tenant }) first`, { cause: e });\n  }\n  throw e;\n}","preventionTips":["Make tenant creation part of deployment scripts (createTenant is idempotent) before any ChromaClient uses the tenant.","Keep server host/port in one shared config so dev/prod never point at different Chroma instances with divergent tenants.","Validate tenant names at config load time (typos, case, whitespace) before constructing clients."],"tags":["tenant","admin-api","multi-tenancy","chroma-server","not-found"],"backgroundTag":"tenant-not-found","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}