TechnitiumSoftware/DnsServer · error · DnsServerException

Failed to update Primary node: the Primary node's domain nam

Error message

Failed to update Primary node: the Primary node's domain name already exists in the Cluster. Please try again after changing the Primary DNS Server's domain name.

What it means

Thrown by UpdatePrimaryNodeAsync during the duplicate-name validation loop: another cluster node (not the one being updated) already has a Name equal (case-insensitive) to primaryNodeUrl.Host. DNS cluster node names must be unique because they map to DNS records and certificate identities.

Source

Thrown at DnsServerCore/Cluster/ClusterManager.cs:1578

                //update cluster nodes
                _clusterNodes = updatedClusterNodes;

                //promote secondary node to primary immediately
                primaryNode.PromoteToPrimaryNode();

                //ensure to save changes
                SaveConfigFile();
            }

            //validate for duplicate names
            foreach (KeyValuePair<int, ClusterNode> clusterNode in _clusterNodes)
            {
                if (clusterNode.Key == primaryNode.Id)
                    continue; //skip self

                if (clusterNode.Value.Name.Equals(primaryNodeUrl.Host, StringComparison.OrdinalIgnoreCase))
                    throw new DnsServerException("Failed to update Primary node: the Primary node's domain name already exists in the Cluster. Please try again after changing the Primary DNS Server's domain name.");
            }

            //get cluster secondary catalog zone
            string clusterCatalogDomain = "cluster-catalog." + _clusterDomain;

            AuthZoneInfo clusterSecondaryCatalogZoneInfo = _dnsWebService.DnsServer.AuthZoneManager.GetAuthZoneInfo(clusterCatalogDomain);
            if (clusterSecondaryCatalogZoneInfo is null)
                throw new DnsServerException($"Failed to update Primary node: the Cluster Secondary Catalog zone '{clusterCatalogDomain}' does not exists.");

            //update primary node
            primaryNode.UpdateNode(primaryNodeUrl, primaryNodeIpAddresses);

            //update cluster catalog zone's primary name server
            clusterSecondaryCatalogZoneInfo.PrimaryNameServerAddresses = primaryNodeIpAddresses.Convert(delegate (IPAddress ipAddress) { return new NameServerAddress(primaryNodeUrl.Host, ipAddress); });

            //save all changes
            _dnsWebService.DnsServer.AuthZoneManager.SaveZoneFile(clusterSecondaryCatalogZoneInfo.Name);
            SaveConfigFile();

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Change the primary DNS server's hostname/domain name to a unique value before updating.
  2. Rename or remove the conflicting cluster node so the name is free.
  3. Validate primaryUrl.Host against all ClusterNodes.Values[].Name (case-insensitive) before submitting.

Example fix

// before
await clusterManager.UpdatePrimaryNodeAsync(primaryUrl, primaryNodeId: id);

// after
string host = primaryUrl.Host;
bool dup = clusterManager.ClusterNodes
    .Where(kv => kv.Key != id)
    .Any(kv => kv.Value.Name.Equals(host, StringComparison.OrdinalIgnoreCase));
if (dup) return Conflict($"Node name '{host}' already in use.");
await clusterManager.UpdatePrimaryNodeAsync(primaryUrl, primaryNodeId: id);
Defensive patterns

Strategy: validation

Validate before calling

string host = primaryUrl.Host;
bool duplicate = clusterManager.ClusterNodes
    .Where(kv => kv.Key != primaryNodeId)
    .Any(kv => kv.Value.Name.Equals(host, StringComparison.OrdinalIgnoreCase));
if (duplicate)
    return Conflict($"Node name '{host}' already used by another cluster node.");
await clusterManager.UpdatePrimaryNodeAsync(primaryUrl, primaryNodeId: primaryNodeId);

Type guard

static bool IsNodeNameUnique(ClusterManager cm, string host, int excludeId)
    => cm.ClusterNodes.Where(kv => kv.Key != excludeId)
         .All(kv => !kv.Value.Name.Equals(host, StringComparison.OrdinalIgnoreCase));

Try / catch

try { await clusterManager.UpdatePrimaryNodeAsync(primaryUrl, primaryNodeId: id); }
catch (DnsServerException ex) when (ex.Message.Contains("domain name already exists"))
{ /* rename the primary DNS server to a unique hostname and retry */ }

Prevention

When it happens

Trigger: Calling UpdatePrimaryNodeAsync with a primaryUrl.Host that collides with an existing cluster node's Name (any node except the one being updated).

Common situations: Reusing a hostname already assigned to a secondary; a node was renamed but the old name lingered; two nodes restored from the same backup; wildcard/alias confusion where Host parses to a shared domain.

Related errors


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