thedotmack/claude-mem · critical
Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_
Error message
Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_URL is not set.
What it means
Thrown by buildPoolFromEnv() in server-bootstrap.ts when parsePostgresConfig({ requireDatabaseUrl: true }) returns null, i.e. CLAUDE_MEM_SERVER_DATABASE_URL (or the equivalent PG env) is not set. The bootstrap cannot create a Postgres pool without a connection string, so it cannot provision the local team/project/API key.
Source
Thrown at src/services/hooks/server-bootstrap.ts:225
`SELECT id FROM projects WHERE team_id = $1 AND name = $2 LIMIT 1`,
[teamId, LOCAL_HOOK_PROJECT_NAME],
);
if (existing.rows[0]) {
return existing.rows[0].id;
}
const repo = new PostgresProjectsRepository(pool);
const project = await repo.create({
teamId,
name: LOCAL_HOOK_PROJECT_NAME,
metadata: { source: 'local-hook-bootstrap' },
});
return project.id;
}
function buildPoolFromEnv(): PostgresPool {
const config = parsePostgresConfig({ requireDatabaseUrl: true });
if (!config) {
throw new Error(
'Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_URL is not set.',
);
}
return createPostgresPool(config);
}
View on GitHub (pinned to d768ba3643)
Solutions
- Set CLAUDE_MEM_SERVER_DATABASE_URL to a valid Postgres connection string and re-run the bootstrap.
- If using a .env file, ensure the bootstrap process actually loads it (or export the var in the same shell).
- Confirm the Postgres instance is reachable from the bootstrap process before re-running.
- If you did not intend server-mode persistence, switch back to worker runtime instead of bootstrapping.
Example fix
# before — bootstrap run with no DB url $ claude-mem bootstrap // throws 'Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_URL is not set.' # after export CLAUDE_MEM_SERVER_DATABASE_URL='postgres://user:pass@localhost:5432/claude_mem' claude-mem bootstrap
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL) {
throw new Error('CLAUDE_MEM_SERVER_DATABASE_URL must be set before running server bootstrap');
} Type guard
function hasDatabaseUrl(): boolean {
return typeof process.env.CLAUDE_MEM_SERVER_DATABASE_URL === 'string'
&& process.env.CLAUDE_MEM_SERVER_DATABASE_URL.length > 0;
} Prevention
- Set CLAUDE_MEM_SERVER_DATABASE_URL in the bootstrap process env (or a loaded .env) before running.
- Confirm Postgres reachability before bootstrap to avoid a later pool-creation failure.
- If you do not need server-mode persistence, stay on worker runtime instead of bootstrapping.
When it happens
Trigger: Running the server API-key bootstrap flow (which creates the local hook team/project and writes credentials) without CLAUDE_MEM_SERVER_DATABASE_URL in env. parsePostgresConfig yields null and the guard throws.
Common situations: First-time server-mode setup where the DATABASE_URL was never exported; .env file not loaded by the bootstrap process; URL was set in a different shell; migrating hosts and forgetting to copy the DB env.
Related errors
- CLAUDE_MEM_SERVER_DATABASE_URL is required for `server ${com
- server startup configuration is invalid: - ${line}
- transport
- missing_api_key
- Postgres requires CLAUDE_MEM_SERVER_DATABASE_URL
AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12).
Data as JSON: /api/errors/57b6c5c9a5a4c501.
Report an issue: GitHub.