TechnitiumSoftware/DnsServer · error · ArgumentException

At least one primary name server address must be specified…

Error message

At least one primary name server address must be specified for {} zone.

What it means

Thrown by the SecondaryForwarderZone.PrimaryNameServerAddresses setter when value is null or has zero entries. A secondary conditional forwarder must know where to forward queries, so an empty upstream list is rejected with ArgumentException naming the property.

Solutions

  1. Provide at least one NameServerAddress before assigning PrimaryNameServerAddresses.
  2. Validate the upstream list is non-empty before constructing/assigning the zone.
  3. Treat an empty upstream list as a configuration error at the source (config parser).

Example fix

// before
zone.PrimaryNameServerAddresses = servers; // servers is null/empty

// after
if (servers is null || servers.Count == 0)
    throw new ArgumentException("upstream servers required");
zone.PrimaryNameServerAddresses = servers;
Defensive patterns

Strategy: validation

Validate before calling

if (value is null || value.Count == 0)
    throw new ArgumentException("At least one upstream name server is required.");
zone.PrimaryNameServerAddresses = value;

Type guard

static bool HasUpstream(IReadOnlyList<NameServerAddress> v) =>
    v is not null && v.Count > 0;

Try / catch

null

Prevention

When it happens

Trigger: Setting zone.PrimaryNameServerAddresses = null or an empty list on a SecondaryForwarderZone.

Common situations: Building a forwarder zone from a config where upstream servers are optional and were omitted; clearing servers during reconfiguration before setting new ones; deserialization producing an empty array.

Related errors


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

Appendix: source

Thrown at DnsServerCore/Dns/Zones/SecondaryForwarderZone.cs:152

            {
                switch (value)
                {
                    case AuthZoneUpdate.AllowOnlyZoneNameServers:
                    case AuthZoneUpdate.AllowZoneNameServersAndUseSpecifiedNetworkACL:
                        throw new ArgumentException("The Dynamic Updates option is invalid for Secondary Conditional Forwarder zones: " + value.ToString(), nameof(Update));
                }

                base.Update = value;
            }
        }

        public override IReadOnlyList<NameServerAddress> PrimaryNameServerAddresses
        {
            get { return base.PrimaryNameServerAddresses; }
            set
            {
                if ((value is null) || (value.Count == 0))
                    throw new ArgumentException("At least one primary name server address must be specified for " + GetZoneTypeName() + " zone.", nameof(PrimaryNameServerAddresses));

                base.PrimaryNameServerAddresses = value;
            }
        }

        public override bool ValidateZone
        {
            get { return base.ValidateZone; }
            set { throw new InvalidOperationException(); }
        }

        #endregion
    }
}

View on GitHub (pinned to d0484b6c1e)