thedotmack/claude-mem · error
Invalid CLAUDE_MEM_REDIS_PORT=
Error message
Invalid CLAUDE_MEM_REDIS_PORT=${value}; expected a TCP port What it means
Thrown by parseRedisPort when CLAUDE_MEM_REDIS_PORT is not a valid TCP port: parseInt must yield an integer in the range 1–65535. The function rejects non-numeric strings, 0, negative numbers, and ports above 65535 (including parseInt truncations it validates against). This guards the Redis connection from being built with an impossible port.
Solutions
- Set CLAUDE_MEM_REDIS_PORT to a plain integer between 1 and 65535 (Redis default: 6379)
- Remove the variable if you connect via CLAUDE_MEM_REDIS_URL which carries its own port
- Strip quotes, whitespace, and any URL prefix so only digits remain
- Verify the value with: node -e "const p=parseInt(process.env.CLAUDE_MEM_REDIS_PORT,10); console.log(Number.isInteger(p)&&p>0&&p<=65535)"
Example fix
// before (.env) CLAUDE_MEM_REDIS_PORT=redis://localhost:6379 // after CLAUDE_MEM_REDIS_PORT=6379
Defensive patterns
Strategy: validation
Validate before calling
const raw = process.env.CLAUDE_MEM_REDIS_PORT;
if (raw !== undefined) {
const port = Number(raw);
if (!Number.isInteger(port) || port < 1 || port > 65535) {
throw new Error(`CLAUDE_MEM_REDIS_PORT must be an integer 1-65535; got "${raw}"`);
}
} Type guard
function isValidTcpPort(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= 65535;
} Try / catch
try {
const config = getRedisQueueConfig();
} catch (err) {
if (err instanceof Error && err.message.includes('CLAUDE_MEM_REDIS_PORT')) {
console.error('Set CLAUDE_MEM_REDIS_PORT to a bare integer like 6379; URL goes in CLAUDE_MEM_REDIS_URL');
}
throw err;
} Prevention
- Only ever put digits in *_PORT variables — full URLs belong in *_URL variables
- Validate port range (1-65535) in a startup env schema
- Prefer CLAUDE_MEM_REDIS_URL (with embedded port) over separate host/port vars to reduce config surface
- Beware parseInt silently truncating; validate the raw string is all digits before parsing
When it happens
Trigger: CLAUDE_MEM_REDIS_PORT set to '' , 'abc', '0', '-1', '99999', '65536', or a float-like string '6379.5' (parseInt gives 6379, but 'http://host:port' garbage or '637 9' parse to invalid values). Triggered while getRedisQueueConfig() builds the Redis connection for external/managed modes.
Common situations: Pasting a full redis:// URL into the PORT variable instead of just the number; leaving the placeholder empty; port typo like 63790 (out of range is rare, usually it's non-numeric); Windows line endings or stray characters embedded in the env value from a script.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- Invalid CLAUDE_MEM_REDIS_MODE=
- CLAUDE_MEM_REDIS_URL must use redis:// or rediss://
- Invalid CLAUDE_MEM_QUEUE_ENGINE=
- Invalid Redis database in CLAUDE_MEM_REDIS_URL
- server startup configuration is invalid:
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/e425f1c3ef497f3d.
Report an issue: GitHub.
Appendix: source
Thrown at src/server/queue/redis-config.ts:74
if (value !== undefined) {
return value;
}
}
return SettingsDefaultsManager.get(key);
}
function normalizeRedisMode(value: string): RedisMode {
const normalized = value.trim().toLowerCase();
if (normalized === 'external' || normalized === 'managed' || normalized === 'docker') {
return normalized;
}
throw new Error(`Invalid CLAUDE_MEM_REDIS_MODE=${value}; expected external, managed, or docker`);
}
function parseRedisPort(value: string): number {
const port = Number.parseInt(value, 10);
if (!Number.isInteger(port) || port <= 0 || port > 65535) {
throw new Error(`Invalid CLAUDE_MEM_REDIS_PORT=${value}; expected a TCP port`);
}
return port;
}
function sanitizePrefix(value: string): string {
return (value.trim() || 'claude_mem').replace(/[^a-zA-Z0-9_-]/g, '_');
}
function connectionFromHost(host: string, port: number): RedisOptions {
return {
host,
port,
maxRetriesPerRequest: null,
connectTimeout: 1000,
lazyConnect: true,
};
}
View on GitHub (pinned to d8bc9755e7)