TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException

Serve stale reset TTL must be between {SERVE_STALE_MIN_RESET

Error message

Serve stale reset TTL must be between {SERVE_STALE_MIN_RESET_TTL} and {SERVE_STALE_MAX_RESET_TTL} seconds. Recommended value is 30 seconds.

What it means

Thrown by the ServeStaleResetTtl property setter when value is below SERVE_STALE_MIN_RESET_TTL or above SERVE_STALE_MAX_RESET_TTL. Serve-stale (serving expired records while refreshing) uses this reset TTL; the bounds keep behavior sane. The recommended value of 30 seconds is noted in the message.

Source

Thrown at DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs:1225

                        return null; //no cached delegation found
                }
            }

            //no cached delegation found
            return null;
        }

        #endregion

        #region properties

        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

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Set ServeStaleResetTtl to a value within [SERVE_STALE_MIN_RESET_TTL, SERVE_STALE_MAX_RESET_TTL]; use the recommended 30 seconds if unsure.
  2. Confirm the unit is seconds, not milliseconds.
  3. Read the named constants' values from the class to know the exact bounds before configuring.

Example fix

// before
_cacheZoneManager.ServeStaleResetTtl = 0; // below min -> throws
// after
_cacheZoneManager.ServeStaleResetTtl = 30; // recommended value (seconds)
Defensive patterns

Strategy: validation

Validate before calling

uint ttl = value;
if (ttl < CacheZoneManager.SERVE_STALE_MIN_RESET_TTL || ttl > CacheZoneManager.SERVE_STALE_MAX_RESET_TTL)
    ttl = 30u; // recommended default
cacheZoneManager.ServeStaleResetTtl = ttl;

Type guard

static bool IsValidServeStaleResetTtl(uint v) => v >= CacheZoneManager.SERVE_STALE_MIN_RESET_TTL && v <= CacheZoneManager.SERVE_STALE_MAX_RESET_TTL;

Try / catch

try { cacheZoneManager.ServeStaleResetTtl = value; }
catch (ArgumentOutOfRangeException) { cacheZoneManager.ServeStaleResetTtl = 30u; }

Prevention

When it happens

Trigger: Setting ServeStaleResetTtl to 0, a sub-minimum value, or above the maximum; unit confusion (passing milliseconds into a seconds field).

Common situations: Tuning serve-stale and entering an out-of-range number; config import with an invalid value; assuming 0 disables it (it does not - the field has a positive minimum).

Related errors


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