cube-js/cube · error · Error
Please specify CUBEJS_DB_URL
Error message
Please specify CUBEJS_DB_URL
What it means
DruidDriver's constructor resolves the Druid SQL endpoint URL from config. If neither a url/CUBEJS_DB_URL nor a usable host+port pair (CUBEJS_DB_HOST and CUBEJS_DB_PORT) is provided, it throws 'Please specify CUBEJS_DB_URL' at driver instantiation time.
Source
Thrown at packages/cubejs-druid-driver/src/DruidDriver.ts:90
});
const dataSource =
config.dataSource ||
assertDataSource('default');
const preAggregations = config.preAggregations || false;
let url = config.url || getEnv('dbUrl', { dataSource, preAggregations });
if (!url) {
const host = getEnv('dbHost', { dataSource, preAggregations });
const port = getEnv('dbPort', { dataSource, preAggregations });
if (host && port) {
const protocol = getEnv('dbSsl', { dataSource, preAggregations })
? 'https'
: 'http';
url = `${protocol}://${host}:${port}`;
} else {
throw new Error('Please specify CUBEJS_DB_URL');
}
}
this.config = {
url,
user:
config.user ||
getEnv('dbUser', { dataSource, preAggregations }),
password:
config.password ||
getEnv('dbPass', { dataSource, preAggregations }),
database:
config.database ||
getEnv('dbName', { dataSource, preAggregations }) ||
'default',
...config,
};
this.client = new DruidClient(this.config);
}View on GitHub (pinned to 7d981676b3)
Solutions
- Set CUBEJS_DB_URL, e.g. CUBEJS_DB_URL=http://druid-broker:8082.
- Or set both CUBEJS_DB_HOST and CUBEJS_DB_PORT so the driver can build the URL.
- Pass `url` explicitly in the driver options object when constructing the driver programmatically.
Example fix
// before (.env) CUBEJS_DB_TYPE=druid CUBEJS_DB_HOST=druid-broker // after CUBEJS_DB_TYPE=druid CUBEJS_DB_URL=http://druid-broker:8082 # or: CUBEJS_DB_HOST=druid-broker + CUBEJS_DB_PORT=8082
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.CUBEJS_DB_URL && !(process.env.CUBEJS_DB_HOST && process.env.CUBEJS_DB_PORT)) {
throw new Error('Provide CUBEJS_DB_URL or CUBEJS_DB_HOST+CUBEJS_DB_PORT for Druid');
} Type guard
function hasDruidEndpoint(cfg) {
return Boolean(cfg?.url || (cfg?.host && cfg?.port));
} Try / catch
try {
const driver = new DruidDriver(config);
} catch (e) {
if (e.message === 'Please specify CUBEJS_DB_URL') {
console.error('Druid endpoint missing: set CUBEJS_DB_URL');
} else throw e;
} Prevention
- Validate required env vars at app startup
- Set CUBEJS_DB_URL including protocol and broker port (usually 8082)
- Keep secrets/urls defined in deployment manifests, not ad hoc shells
When it happens
Trigger: Creating a DruidDriver (or starting Cube with dbType: 'druid') without `url` in config and without both `host` and `port` set — e.g. CUBEJS_DB_URL unset and CUBEJS_DB_HOST missing or CUBEJS_DB_PORT missing.
Common situations: Incomplete .env during initial setup; only CUBEJS_DB_HOST provided without a port; typo'd env var name so the config field is undefined; Kubernetes secret missing the URL key.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- CUBEJS_DB_NAME can`t be empty.
- You are using an old version of Druid. Unable to detect colu
- Unexpected return type, driverFactory must return driver (da
- unknown env variable {}
- A user-defined contextToApiScopes function returns an incons
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/0893552e5e0cd73f.
Report an issue: GitHub.