TechnitiumSoftware/DnsServer · error · DnsWebServiceException

Group already exists: {name}

Error message

Group already exists: {name}

What it means

Thrown as DnsWebServiceException from CreateGroup when _groups.TryAdd(name.ToLowerInvariant(), group) returns false because a group with that name already exists. Group keys are stored lowercased, so the check is case-insensitive. Returned over the API as HTTP 200 with status 'error'.

Source

Thrown at DnsServerCore/Auth/AuthManager.cs:1075

        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)
        {
            if (group.Name.Equals(newGroupName, StringComparison.OrdinalIgnoreCase))
            {
                group.Name = newGroupName;
                return;
            }

            string oldGroupName = group.Name;
            group.Name = newGroupName;

            if (!_groups.TryAdd(group.Name.ToLowerInvariant(), group))
            {
                group.Name = oldGroupName; //revert
                throw new DnsWebServiceException("Group already exists: " + newGroupName);
            }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Check whether the group exists (case-insensitively) before creating.
  2. Choose a unique group name.
  3. Delete the existing group first (note: built-in groups cannot be deleted).

Example fix

// before
_authManager.CreateGroup(name, description);
// after
if (!_groups.ContainsKey(name.ToLowerInvariant()))
    _authManager.CreateGroup(name, description);
Defensive patterns

Strategy: validation

Validate before calling

if (await GetGroupAsync(name) is not null)
    throw new InvalidOperationException($"Group '{name}' already exists.");

Try / catch

try { await client.CreateGroupAsync(name, description); }
catch (HttpApiClientException ex) when (ex.Message.StartsWith("Group already exists"))
{
    // use existing group instead
}

Prevention

When it happens

Trigger: Creating a group whose lowercased name matches an existing group key; case-only differences collide.

Common situations: Re-running a setup script; a built-in group like 'everyone' or 'administrators' already exists with the target name.

Related errors


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