TechnitiumSoftware/DnsServer · error · InvalidOperationException

Zone was not found: {zoneName}

Error message

Zone was not found: {zoneName}

What it means

Thrown by QueryZoneTransferRecords when GetAuthZoneInfo(zoneName) returns null, meaning no zone with that name exists in the zone tree. This is an InvalidOperationException (not DnsServerException) because it indicates a programming or protocol-level error rather than a user-facing DNS operation error. Zone transfer queries require an existing zone.

Source

Thrown at DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs:2471

                if (authZone is SubDomainZone subDomainZone)
                {
                    if (authZone.IsEmpty)
                        _root.TryRemove(authZone.Name, out SubDomainZone _); //remove empty sub zone
                    else
                        subDomainZone.AutoUpdateState();
                }
            }
        }

        #endregion

        #region zone transfer / import

        public IReadOnlyList<DnsResourceRecord> QueryZoneTransferRecords(string zoneName)
        {
            AuthZoneInfo zoneInfo = GetAuthZoneInfo(zoneName);
            if (zoneInfo is null)
                throw new InvalidOperationException("Zone was not found: " + zoneName);

            //primary, secondary, and forwarder zones support zone transfer
            IReadOnlyList<DnsResourceRecord> soaRecords = zoneInfo.ApexZone.GetRecords(DnsResourceRecordType.SOA);
            if (soaRecords.Count != 1)
                throw new InvalidOperationException("Zone must be a primary, secondary, or forwarder zone.");

            DnsResourceRecord soaRecord = soaRecords[0];

            List<DnsResourceRecord> records = new List<DnsResourceRecord>();
            ListAllZoneRecords(zoneName, records);

            List<DnsResourceRecord> xfrRecords = new List<DnsResourceRecord>(records.Count + 1);

            //start message
            xfrRecords.Add(soaRecord);

            foreach (DnsResourceRecord record in records)
            {

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Verify the zone exists by calling GetAuthZoneInfo before requesting a zone transfer.
  2. Check the zone name spelling and format in the transfer configuration.
  3. Ensure the zone was loaded successfully at server startup.
  4. For secondary servers, validate the primary zone name matches exactly.

Example fix

// before
var xfrRecords = authZoneManager.QueryZoneTransferRecords(zoneName);

// after
AuthZoneInfo info = authZoneManager.GetAuthZoneInfo(zoneName);
if (info is null)
    throw new InvalidOperationException($"Cannot transfer: zone '{zoneName}' does not exist.");
var xfrRecords = authZoneManager.QueryZoneTransferRecords(zoneName);
Defensive patterns

Strategy: validation

Validate before calling

AuthZoneInfo info = authZoneManager.GetAuthZoneInfo(zoneName);
if (info is null)
    throw new InvalidOperationException($"Cannot transfer: zone '{zoneName}' does not exist.");

Type guard

static bool ZoneExists(AuthZoneManager mgr, string zoneName)
    => mgr.GetAuthZoneInfo(zoneName) is not null;

Try / catch

try
{
    var records = authZoneManager.QueryZoneTransferRecords(zoneName);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Zone was not found"))
{
    logger.LogError("AXFR failed: zone '{Zone}' does not exist.", zoneName);
}

Prevention

When it happens

Trigger: Calling QueryZoneTransferRecords(zoneName) where zoneName does not match any registered zone. This method is the AXFR data source; a secondary server requesting transfer for an unknown zone, or internal code passing a wrong name, triggers it.

Common situations: Secondary server configured to transfer a zone that the primary does not host; zone name typo in transfer configuration; zone was deleted but transfer schedule still runs; root zone edge case where zoneName is empty string and no root zone exists.

Related errors


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