TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Valid range is from 8 KB to 65536 KB.
Error message
Valid range is from 8 KB to 65536 KB.
What it means
Thrown by the UdpSendBufferSizeKB setter. It configures the SO_SNDBUF socket buffer size (in KB) used for outbound UDP DNS responses. The setter enforces [8, 65536] KB (i.e. 8 KB to 64 MB). Anything outside that band throws ArgumentOutOfRangeException on assignment from the settings API or config loader.
Source
Thrown at DnsServerCore/Dns/DnsServer.cs:7572
throw new ArgumentOutOfRangeException(nameof(QuicMaxInboundStreams), "Valid range is from 1 to 1000.");
_quicMaxInboundStreams = value;
}
}
public int ListenBacklog
{
get { return _listenBacklog; }
set { _listenBacklog = value; }
}
public int UdpSendBufferSizeKB
{
get { return _udpSendBufferSizeKB; }
set
{
if ((value < 8) || (value > 65536))
throw new ArgumentOutOfRangeException(nameof(UdpSendBufferSizeKB), "Valid range is from 8 KB to 65536 KB.");
_udpSendBufferSizeKB = value;
}
}
public int UdpReceiveBufferSizeKB
{
get { return _udpReceiveBufferSizeKB; }
set
{
if ((value < 8) || (value > 65536))
throw new ArgumentOutOfRangeException(nameof(UdpReceiveBufferSizeKB), "Valid range is from 8 KB to 65536 KB.");
_udpReceiveBufferSizeKB = value;
}
}
public ushort MaxConcurrentResolutionsPerCoreView on GitHub (pinned to d0484b6c1e)
Solutions
- Provide a value in KB within 8..65536 (e.g. 1024 for a 1 MB send buffer).
- Confirm the unit is kilobytes, not bytes — multiply/divide by 1024 accordingly.
- For high-throughput servers, a value such as 4096-8192 KB is typical; never exceed 65536.
- Validate config ints before assignment so a corrupt value does not crash settings load.
Example fix
// before _dnsServer.UdpSendBufferSizeKB = 8192; // meant 8KB in bytes, actually 8MB (valid but wrong) / or 4 (throws) // after _dnsServer.UdpSendBufferSizeKB = 1024; // 1 MB, clearly within 8..65536 KB
Defensive patterns
Strategy: validation
Validate before calling
static int ClampBufferKB(int value) =>
value < 8 ? 8 : value > 65536 ? 65536 : value;
_dnsServer.UdpSendBufferSizeKB = ClampBufferKB(parsedKB); Type guard
static bool IsValidBufferSizeKB(int value) => value >= 8 && value <= 65536;
Try / catch
try { _dnsServer.UdpSendBufferSizeKB = parsedKB; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(DnsServer.UdpSendBufferSizeKB))
{ _dnsServer.UdpSendBufferSizeKB = 1024; } Prevention
- Confirm the unit is kilobytes, not bytes.
- Keep send and receive buffer sizes consistent.
- Validate config ints to [8, 65536] KB before assignment.
When it happens
Trigger: Assigning DnsServer.UdpSendBufferSizeKB a value < 8 or > 65536. Occurs via WebServiceSettingsApi.cs:875 settings update or via a binary config int read that yields an out-of-range value.
Common situations: Confusing KB and bytes (e.g. passing 8192 meaning 8 KB in bytes -> 8192 KB = 8 MB, which is valid but unintended; or passing 8 meaning bytes -> 8 KB). Setting 0 or 1 to 'disable' buffering. Raising the buffer to absorb large DNS responses but exceeding the 64 MB cap.
Related errors
- Invalid EDNS UDP payload size: valid range is 512-4096 bytes
- Percentage value valid range is between 0 and 100.
- Valid range is from 1 to 1000.
- Value cannot be less than 1.
- Port number valid range is from 0 to 65535.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/44c5b440f11df27c.
Report an issue: GitHub.