TechnitiumSoftware/DnsServer · error · FormatException
Invalid AdGuard Upstreams config file format: missing upstre
Error message
Invalid AdGuard Upstreams config file format: missing upstream servers.
What it means
Thrown while parsing an AdGuard Upstreams file when a domain-scoped line declares an explicit upstream server list after the ']' bracket but none could be parsed (the forwarderRecords list stayed empty after consuming the line). FormatException is raised.
Source
Thrown at Apps/AdvancedForwardingApp/App.cs:680
string word = PopWord(ref forwarder);
while (word.Length > 0)
{
string nextWord = PopWord(ref forwarder);
if (nextWord.StartsWith('('))
{
word += " " + nextWord;
nextWord = PopWord(ref forwarder);
}
forwarderRecords.Add(GetForwarderRecord(NameServerAddress.Parse(word), _dnssecValidation, _configProxyServer));
word = nextWord;
}
if (forwarderRecords.Count == 0)
throw new FormatException("Invalid AdGuard Upstreams config file format: missing upstream servers.");
forwardings.Add(new Forwarding(forwarderRecords, domains));
}
}
else
{
defaultForwarderRecords.Add(GetForwarderRecord(NameServerAddress.Parse(line), _dnssecValidation, _configProxyServer));
}
}
_configFileLastModified = File.GetLastWriteTimeUtc(fS.SafeFileHandle);
}
_defaultForwarderRecords = defaultForwarderRecords;
_forwardings = forwardings;
_dnsServer.WriteLog("The app has successfully loaded AdGuard Upstreams config file: " + _configFile);
}View on GitHub (pinned to d0484b6c1e)
Solutions
- Add one or more valid upstream servers after the ']' on that line, e.g. '[/example.com/] tls://1.1.1.1'.
- Ensure each server token is a value NameServerAddress.Parse can accept (IP, DoH/DoT URL).
- If the domain should use the default upstream, use '#' instead of leaving it blank.
Example fix
// before (upstreams file) [/example.com/] // after [/example.com/] https://dns.google/dns-query
Defensive patterns
Strategy: validation
Validate before calling
foreach (string line in File.ReadAllLines(upstreamsPath))
{
string t = line.TrimStart();
if (t.StartsWith('['))
{
int i = t.LastIndexOf(']');
if (i >= 0 && t.Substring(i + 1).Trim() == string.Empty)
throw new FormatException($"AdGuard upstreams line has no server after ']': {line}");
}
} Prevention
- Always put at least one upstream server token after the ']' bracket.
- Use '#' only when a default upstream is defined.
- Lint upstreams files for empty post-bracket server lists.
When it happens
Trigger: An AdGuard upstreams line like '[/example.com/]' with no server tokens after the bracket, or whose post-bracket text is only whitespace/parentheses, leaving zero upstream records.
Common situations: Trailing whitespace after ']' with no server; malformed parenthesis grouping consumed by PopWord but yielding no server; copy-paste that dropped the server name.
Related errors
- Invalid AdGuard Upstreams config file format: missing ']' br
- Invalid AdGuard Upstreams config file format: missing defaul
- Network group map contains an invalid network address: {netw
- Groups array was not defined.
- Forwarder was not defined: {forwarderName}
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/a8c7fc42eee07eef.
Report an issue: GitHub.