TechnitiumSoftware/DnsServer · error · DnsWebServiceException

Cannot create more than 255 groups.

Error message

Cannot create more than 255 groups.

What it means

Thrown as DnsWebServiceException from CreateGroup when _groups.Count >= 255 (byte.MaxValue) before adding. Group identifiers are stored as a byte, hence the 255 cap. Returned over the API as HTTP 200 with status 'error'.

Source

Thrown at DnsServerCore/Auth/AuthManager.cs:1060

        public void SyncGroupMembers(Group group, IReadOnlyDictionary<string, User> users)
        {
            //remove
            foreach (KeyValuePair<string, User> user in _users)
            {
                if (!users.ContainsKey(user.Key))
                    user.Value.RemoveFromGroup(group);
            }

            //set
            foreach (KeyValuePair<string, User> user in users)
                user.Value.AddToGroup(group);
        }

        public Group CreateGroup(string name, string description)
        {
            if (_groups.Count >= byte.MaxValue)
                throw new DnsWebServiceException("Cannot create more than 255 groups.");

            Group group = new Group(name, description);

            if (_groups.TryAdd(name.ToLowerInvariant(), group))
            {
                if (_groups.Count > byte.MaxValue)
                {
                    _groups.TryRemove(name.ToLowerInvariant(), out _); //undo
                    throw new DnsWebServiceException("Cannot create more than 255 groups.");
                }

                return group;
            }

            throw new DnsWebServiceException("Group already exists: " + name);
        }

        public void RenameGroup(Group group, string newGroupName)

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Delete unused groups to free slots below 255.
  2. Reorganize permissions to need fewer groups.
  3. Check the group count before bulk-provisioning.
Defensive patterns

Strategy: validation

Validate before calling

if (await GetGroupCountAsync() >= 255)
    throw new InvalidOperationException("Group cap (255) reached; delete unused groups first.");

Try / catch

try { await client.CreateGroupAsync(name, description); }
catch (HttpApiClientException ex) when (ex.Message.Contains("Cannot create more than 255 groups"))
{
    await FreeUpGroupSlotsAsync();
}

Prevention

When it happens

Trigger: POST /api/groups/create (or equivalent) when 255 groups already exist; the pre-add guard fails fast.

Common situations: Bulk group creation; long-lived server that accumulated groups up to the cap.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/f10eb152dedd0211. Report an issue: GitHub.