TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Invalid cache maximum entries value. Valid range is 0 and ab
Error message
Invalid cache maximum entries value. Valid range is 0 and above.
What it means
Thrown by the MaximumEntries property setter when value is less than 0. The cache maximum-entries cap must be zero or positive (0 typically means unlimited/auto), so any negative number is rejected.
Source
Thrown at DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs:1237
public uint ServeStaleResetTtl
{
get { return _serveStaleResetTtl; }
set
{
if ((value < SERVE_STALE_MIN_RESET_TTL) || (value > SERVE_STALE_MAX_RESET_TTL))
throw new ArgumentOutOfRangeException(nameof(ServeStaleResetTtl), "Serve stale reset TTL must be between " + SERVE_STALE_MIN_RESET_TTL + " and " + SERVE_STALE_MAX_RESET_TTL + " seconds. Recommended value is 30 seconds.");
_serveStaleResetTtl = value;
}
}
public long MaximumEntries
{
get { return _maximumEntries; }
set
{
if (value < 0)
throw new ArgumentOutOfRangeException(nameof(MaximumEntries), "Invalid cache maximum entries value. Valid range is 0 and above.");
_maximumEntries = value;
}
}
public long TotalEntries
{ get { return _totalEntries; } }
#endregion
}
}
View on GitHub (pinned to d0484b6c1e)
Solutions
- Pass 0 (unlimited) or a positive number for MaximumEntries.
- Clamp computed values to >= 0 before assigning.
- Validate the configured value against the documented range before applying.
Example fix
// before _cacheZoneManager.MaximumEntries = -1; // < 0 -> throws // after _cacheZoneManager.MaximumEntries = 0; // 0 = unlimited, or use a positive cap
Defensive patterns
Strategy: validation
Validate before calling
long max = requestedMaximumEntries < 0 ? 0 : requestedMaximumEntries; cacheZoneManager.MaximumEntries = max;
Type guard
static bool IsValidMaximumEntries(long v) => v >= 0;
Try / catch
try { cacheZoneManager.MaximumEntries = value; }
catch (ArgumentOutOfRangeException) { cacheZoneManager.MaximumEntries = Math.Max(0, value); } Prevention
- Clamp capacity computations to >= 0.
- Use 0 for unlimited when unsure.
- Validate config-sourced values before applying.
- Guard against arithmetic underflow in size calculations.
When it happens
Trigger: Setting MaximumEntries to a negative number; arithmetic that underflows (e.g. subtracting from a base); config import with a bad value.
Common situations: Script computes capacity from memory/disk and produces a negative; typo/negative literal; stale config value.
Related errors
- Serve stale max wait time valid range is 0 to 1800 milliseco
- Serve stale reset TTL must be between {SERVE_STALE_MIN_RESET
- DNS-over-HTTP Real IP header name cannot exceed 255 characte
- DNS-over-HTTP Real IP header name cannot contain invalid cha
- TSIG keys cannot have more than 255 entries.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/4eb07dff12d00002.
Report an issue: GitHub.