TechnitiumSoftware/DnsServer · error · ArgumentException

Cannot configure more than 255 block list URLs.

Error message

Cannot configure more than 255 block list URLs.

What it means

Thrown by the BlockListUrls property setter when more than 255 entries are supplied. The count is persisted as a single byte (bW.Write(Convert.ToByte(_blockListUrls.Count))), so the cap is hard 255. Null is allowed (treated as empty), but any non-null collection over 255 is rejected.

Source

Thrown at DnsServerCore/Dns/ZoneManagers/BlockListZoneManager.cs:1036

                temporaryDisableBlockingTimer.Dispose();
        }

        #endregion

        #region properties

        public IReadOnlyList<string> BlockListUrls
        {
            get { return _blockListUrls; }
            set
            {
                if (value is null)
                {
                    value = [];
                }
                else if (value.Count > 255)
                {
                    throw new ArgumentException("Cannot configure more than 255 block list URLs.", nameof(BlockListUrls));
                }
                else
                {
                    List<string> uniqueList = new List<string>(value.Count);
                    int commentCount = 0;

                    foreach (string url in value)
                    {
                        if (url.Length > 255)
                            throw new ArgumentException("Block list URL (or comment line) length cannot exceed 255 characters.", nameof(BlockListUrls));

                        if (url.TrimStart().StartsWith('#'))
                        {
                            uniqueList.Add(url);
                            commentCount++;
                            continue;
                        }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Trim the list to at most 255 URLs (prefer deduplicating first to reclaim slots).
  2. Consolidate multiple small lists into fewer combined upstream lists.
  3. Offload excess blocking to a DNS RPZ or blocked-zone rule set instead of the URL-based block list.

Example fix

// before
blockListZoneManager.BlockListUrls = allUrls; // Count == 300 -> throws
// after
blockListZoneManager.BlockListUrls = allUrls.Distinct().Take(255).ToList();
Defensive patterns

Strategy: validation

Validate before calling

if (urls != null && urls.Count > 255)
    throw new InvalidOperationException($"Trim block list URLs to <= 255 (got {urls.Count}).");
blockListZoneManager.BlockListUrls = urls;

Type guard

static bool IsValidBlockListUrlCount(IReadOnlyList<string> urls) => urls is null || urls.Count <= 255;

Try / catch

try { blockListZoneManager.BlockListUrls = urls; }
catch (ArgumentException ex) when (ex.Message.Contains("255 block list URLs"))
{ blockListZoneManager.BlockListUrls = urls.Distinct().Take(255).ToList(); }

Prevention

When it happens

Trigger: Assigning an IReadOnlyList<string> with Count > 255 to BlockListUrls; bulk-loading a large subscription list that exceeds the byte-width limit.

Common situations: Operator subscribes to many ad-block / malware block list feeds exceeding 255 combined entries; merging several lists into one configured set.

Related errors


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