TechnitiumSoftware/DnsServer · error · DnsServerException

Zone was not found: {zoneName}

Error message

Zone was not found: {zoneName}

What it means

Thrown by AuthZoneTree.GetOrAddSubDomainZone when the apex case (zoneName == domain) is true and the AuthZoneNode for the domain was found/added, but its ApexZone property is null. This means the node exists in the tree without an attached apex zone, which is an inconsistent internal state that the method refuses to return.

Source

Thrown at DnsServerCore/Dns/Trees/AuthZoneTree.cs:647

            return zones;
        }

        public AuthZone GetOrAddSubDomainZone(string zoneName, string domain, Func<SubDomainZone> valueFactory)
        {
            bool isApex = zoneName.Equals(domain, StringComparison.OrdinalIgnoreCase);

            AuthZoneNode authZoneNode = GetOrAdd(domain, delegate (string key)
            {
                if (isApex)
                    throw new DnsServerException("Zone was not found for domain: " + key);

                return new AuthZoneNode(valueFactory(), null);
            });

            if (isApex)
            {
                if (authZoneNode.ApexZone is null)
                    throw new DnsServerException("Zone was not found: " + zoneName);

                return authZoneNode.ApexZone;
            }
            else
            {
                return authZoneNode.GetOrAddParentSideZone(valueFactory);
            }
        }

        public AuthZone GetAuthZone(string zoneName, string domain)
        {
            if (TryGet(domain, out AuthZoneNode authZoneNode))
                return authZoneNode.GetAuthZone(zoneName);

            return null;
        }

        public ApexZone GetApexZone(string zoneName)

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Verify the apex zone is fully registered (TryGet(zoneName, out ApexZone) succeeds) before invoking sub-domain operations.
  2. Audit zone deletion code to ensure nodes with null ApexZone are removed from the tree, not left behind.
  3. Treat this as an internal-consistency bug: log the zoneName and restart the zone manager if hit.

Example fix

// before
return authZoneNode.ApexZone; // throws if null in apex path

// after (defensive caller)
if (!_root.TryGet(zoneName, out ApexZone apexZone) || apexZone is null)
    throw new DnsServerException("Apex zone missing or not initialized: " + zoneName);
return apexZone;
Defensive patterns

Strategy: validation

Validate before calling

bool ApexReady(AuthZoneTree root, string zoneName)
    => root.TryGet(zoneName, out var node) && node.ApexZone is not null;

Try / catch

try { return root.GetOrAddSubDomainZone(zoneName, domain, factory); }
catch (DnsServerException ex) when (ex.Message.StartsWith("Zone was not found:"))
{
    _log.Error("AuthZoneNode exists but ApexZone is null: " + zoneName);
    throw;
}

Prevention

When it happens

Trigger: GetOrAdd returns an existing AuthZoneNode whose ApexZone field is null — e.g. a node was inserted as a parent-side-only placeholder (new AuthZoneNode(valueFactory(), null) path) and later an apex-equal lookup occurs; or the apex zone was nulled out while the node remained in the tree.

Common situations: Concurrent zone teardown that nulls an apex but leaves the node in the tree; partial initialization where a sub-domain node was added with a null parent apex; memory/state corruption from a bug in zone deletion.

Related errors


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