Mintplex-Labs/anything-llm · error
Failed to enable multi-user mode.
Error message
Failed to enable multi-user mode.
What it means
400 from POST /system/enable-multi-user. The handler creates the first admin user via User.create; on failure it echoes that error, falling back to this generic string only when no specific error was produced. Typical User.create failures: password complexity (joi-password-complexity, min 8 chars via PASSWORDMINCHAR), invalid username format (must start with a lowercase letter; only lowercase letters, digits, and . _ @ - allowed; 2–64 chars), or a duplicate username (prisma P2002 mapped to 'A user with that ... already exists').
Source
Thrown at server/endpoints/system.js:678
if (response.locals.multiUserMode) {
response.status(200).json({
success: false,
error: "Multi-user mode is already enabled.",
});
return;
}
const { username, password } = reqBody(request);
const { user, error } = await User.create({
username,
password,
role: ROLES.admin,
});
if (error || !user) {
response.status(400).json({
success: false,
error: error || "Failed to enable multi-user mode.",
});
return;
}
await SystemSettings._updateSettings({
multi_user_mode: true,
});
await BrowserExtensionApiKey.migrateApiKeysToMultiUser(user.id);
await Memory.migrateToMultiUser(user.id);
await WorkspaceChats.migrateToMultiUser(user.id);
await WorkspaceThread.migrateToMultiUser(user.id);
await WorkspaceParsedFiles.migrateToMultiUser(user.id);
await MobileDevice.migrateDevicesToMultiUser(user.id);
await SlashCommandPresets.migrateToMultiUser(user.id);
await AgentSkillWhitelist.clearSingleUserWhitelist();
await updateENV(
{
JWTSecret: process.env.JWT_SECRET || v4(),View on GitHub (pinned to 20f6d3546c)
Solutions
- Use a password of at least 8 characters (or whatever PASSWORDMINCHAR demands on this deployment)
- Use a username matching ^[a-z][a-z0-9._@-]{1,63}$ — starts lowercase, no spaces or capitals
- If setup previously half-completed, remove the leftover admin user and retry; on success the endpoint flips multi_user_mode on and migrates single-user data
Example fix
// before
await api.post('/system/enable-multi-user', {
username: 'Admin', password: 'password'
}); // 400
// after
await api.post('/system/enable-multi-user', {
username: 'admin', password: 'at-least-8-chars'
}); Defensive patterns
Strategy: validation
Validate before calling
// Mirror the server's rules before calling /system/enable-multi-user
const USERNAME_RE = /^[a-z][a-z0-9._@-]{1,63}$/;
function isFirstAdminPayload({ username, password }) {
return USERNAME_RE.test(String(username)) && String(password).length >= 8;
}
if (!isFirstAdminPayload(payload)) throw new Error('Username must be lowercase-format; password >= 8 chars'); Type guard
function isFirstAdminInput(v) {
return !!v && typeof v.username === 'string' && typeof v.password === 'string' &&
/^[a-z][a-z0-9._@-]{1,63}$/.test(v.username);
} Prevention
- Validate the username format client-side before first-boot setup
- Read the returned error string — it names the real cause (complexity, username format, duplicate)
- If setup timed out, check whether the admin user was already created before retrying
When it happens
Trigger: First-boot setup POSTing {username:'Admin', password:'password'} — uppercase/short username or weak password; re-running setup after a partial failure left a user row behind; database rejecting the insert.
Common situations: Rushing onboarding with a throwaway password; corporate email-style usernames containing capital letters or spaces; retrying setup after a timeout that actually created the user.
Related errors
- Invalid password.
- Passwords do not match
- click requires <x> <y> coordinates
- type requires <text> argument
- key requires <key> argument (e.g. Enter, Tab, Escape)
AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18).
Data as JSON: /api/errors/02a9e2fb35cf6ec6.
Report an issue: GitHub.