RocketChat/Rocket.Chat · error · Meteor.Error
error-direct-message-max-user-exceeded
error-direct-message-max-user-exceeded
Error message
You cannot add more than ${maxUsers} users, including yourself to a direct message What it means
Meteor.Error('error-direct-message-max-user-exceeded') thrown by createDirectRoom when members.length exceeds the 'DirectMesssage_maxUsers' setting (the setting id really has a triple 's'; the code falls back to 1 when the setting is unset or 0).
Source
Thrown at apps/meteor/server/lib/rooms/createDirectRoom.ts:52
name,
u: {
_id: user._id,
username: user.username,
},
});
export async function createDirectRoom(
members: IUser[] | string[],
roomExtraData: Partial<IRoom> = {},
options: {
forceNew?: boolean;
creator?: IUser['_id'];
subscriptionExtra?: ISubscriptionExtraData;
},
): Promise<ICreatedRoom> {
const maxUsers = settings.get<number>('DirectMesssage_maxUsers') || 1;
if (members.length > maxUsers) {
throw new Meteor.Error(
'error-direct-message-max-user-exceeded',
`You cannot add more than ${maxUsers} users, including yourself to a direct message`,
{
method: 'createDirectRoom',
},
);
}
const membersUsernames: string[] = members
.map((member) => {
if (typeof member === 'string') {
return member;
}
return member.username;
})
.filter(isTruthy);
await callbacks.run('beforeCreateDirectRoom', membersUsernames, roomExtraData);View on GitHub (pinned to b2c16d5842)
Solutions
- Raise the 'DirectMesssage_maxUsers' setting in the administration settings to the desired participant count and save.
- Create a private channel ('p') instead of a DM for larger groups.
- Cap the recipient picker in the UI to the configured limit.
Example fix
// before
await createDirectRoom([...tenMembers]); // throws error-direct-message-max-user-exceeded
// after: create a private room instead for large groups
await createRoom('p', name, { members: tenMembers }); Defensive patterns
Strategy: validation
Validate before calling
const maxUsers = settings.get<number>('DirectMesssage_maxUsers') || 1;
if (members.length > maxUsers) {
// create a private channel instead, or raise the setting
} else {
await createDirectRoom(members, roomExtraData, options);
} Try / catch
try {
await createDirectRoom(members);
} catch (error: any) {
if (error?.error === 'error-direct-message-max-user-exceeded') {
// offer group channel creation or suggest raising DirectMesssage_maxUsers
}
} Prevention
- Cap recipient selection in the UI at the DirectMesssage_maxUsers value.
- Remember the setting id's triple 's' ('DirectMesssage_maxUsers') when scripting.
- Use channels rather than DMs for group conversations beyond the limit.
When it happens
Trigger: Creating a DM whose member count is above the workspace limit: selecting multiple recipients on a workspace with a low DirectMesssage_maxUsers value, or with the setting unset so the fallback of 1 applies.
Common situations: Admin lowered the DM participant limit; expectations about multi-user DMs vs. the configured limit; settings migrations leaving the value unset.
Related errors
- error-user-limit-exceeded
- error-max-rooms-per-guest-reached
- error-invalid-room
- Federation configuration is invalid,unable to change room ow
- Federation configuration is invalid,unable to change room ow
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/22120590952888cb.
Report an issue: GitHub.