Mintplex-Labs/anything-llm · error
Internal Server Error
Error message
Internal Server Error
What it means
Returned by GET /v1/users when User.where() throws after the multiUserMode gate passes. The handler at server/endpoints/api/userManagement/index.js:61 catches any exception from the Prisma query that loads all users. Since the multiUserMode check already passed (meaning the system is properly configured for multi-user), the throw is almost always a database-level issue: Prisma connection failure, schema drift, or a corrupt users table.
Source
Thrown at server/endpoints/api/userManagement/index.js:63
description: "Instance is not in Multi-User mode. Permission denied.",
}
*/
try {
if (!multiUserMode(response))
return response
.status(401)
.send("Instance is not in Multi-User mode. Permission denied.");
const users = await User.where();
const filteredUsers = users.map((user) => ({
id: user.id,
username: user.username,
role: user.role,
}));
response.status(200).json({ users: filteredUsers });
} catch (e) {
console.error(e.message, e);
response.sendStatus(500).end();
}
});
app.get(
"/v1/users/:id/issue-auth-token",
[validApiKey, simpleSSOEnabled],
async (request, response) => {
/*
#swagger.tags = ['User Management']
#swagger.description = 'Issue a temporary auth token for a user'
#swagger.parameters['id'] = {
in: 'path',
description: 'The ID of the user to issue a temporary auth token for',
required: true,
type: 'string'
}
#swagger.responses[200] = {
content: {View on GitHub (pinned to 526360e320)
Solutions
- Verify database connectivity: ensure DATABASE_URL is correct and the database host is reachable from the app container.
- Run `npx prisma migrate deploy` (or the project's migration command) to ensure the schema is up to date.
- Run `npx prisma generate` to regenerate the Prisma client after any schema change.
- Check server logs for the specific Prisma error code (P1001 for connection failure, P2021 for missing table, etc.).
- If using Docker, verify the database service is healthy before starting the app: `docker compose ps`.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const res = await fetch('/v1/users', {
headers: { Authorization: `Bearer ${API_KEY}` }
});
if (res.status === 401) throw new Error('Instance is not in Multi-User mode');
if (res.status === 500) throw new Error('Database error — check DB connectivity and Prisma migrations');
return await res.json();
} catch (e) {
// Check DATABASE_URL and database health before retrying
console.error('Failed to list users:', e.message);
} Prevention
- Always check for 401 first — it means multi-user mode is disabled, not a server error.
- Ensure DATABASE_URL is correct and the database is running before making user management calls.
- Run prisma migrate deploy after every AnythingLLM version upgrade.
- Monitor database connection pool health in production.
When it happens
Trigger: GET /v1/users when the database connection has dropped or the Prisma client cannot reach the database server. Also triggered if the Prisma schema has been migrated but the client was not regenerated (prisma generate), causing a mismatch between the expected and actual table structure. In containerized deployments, this happens when the DB container is restarting or the DATABASE_URL points to an unreachable host.
Common situations: Database container restart or network partition between the app and database. Running a new code version against an old database without running migrations. The DATABASE_URL environment variable is incorrect or the database credentials have expired. Prisma client generated against a different schema version than the running database.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/01a2049e7c7e381b.
Report an issue: GitHub.