TechnitiumSoftware/DnsServer · error · FormatException
Invalid AdGuard Upstreams config file format: missing ']' br
Error message
Invalid AdGuard Upstreams config file format: missing ']' bracket.
What it means
Thrown while parsing an AdGuard Upstreams config file (a separate upstream-format file, not the app JSON config) imported by the AdvancedForwardingApp. A line starting with '[' must contain a matching ']' that delimits the domain list from the upstream server(s). If no ']' is found (LastIndexOf returns -1), the file is rejected with FormatException.
Source
Thrown at Apps/AdvancedForwardingApp/App.cs:647
while (true)
{
line = sR.ReadLine();
if (line is null)
break; //eof
line = line.TrimStart();
if (line.Length == 0)
continue; //skip empty line
if (line.StartsWith('#'))
continue; //skip comment line
if (line.StartsWith('['))
{
int i = line.LastIndexOf(']');
if (i < 0)
throw new FormatException("Invalid AdGuard Upstreams config file format: missing ']' bracket.");
string[] domains = line.Substring(1, i - 1).Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
string forwarder = line.Substring(i + 1);
if (forwarder == "#")
{
if (defaultForwarderRecords.Count == 0)
throw new FormatException("Invalid AdGuard Upstreams config file format: missing default upstream servers.");
forwardings.Add(new Forwarding(defaultForwarderRecords, domains));
}
else
{
List<DnsForwarderRecordData> forwarderRecords = new List<DnsForwarderRecordData>();
string word = PopWord(ref forwarder);
while (word.Length > 0)
{View on GitHub (pinned to d0484b6c1e)
Solutions
- Open the referenced AdGuard upstreams file and add the missing ']' bracket on the indicated line, using the syntax [/domain1/domain2/] upstream1 upstream2.
- Re-download or re-export the upstreams file from a known-good AdGuard source to restore correct formatting.
- Validate every '['-prefixed line ends its domain section with ']' before the upstream servers.
Example fix
// before (upstreams file) [/example.com/ 1.1.1.1 // after [/example.com/] 1.1.1.1
Defensive patterns
Strategy: validation
Validate before calling
// Validate each '['-prefixed line of an AdGuard upstreams file has a matching ']'.
foreach (string line in File.ReadAllLines(upstreamsPath))
{
string t = line.TrimStart();
if (t.StartsWith('[') && t.LastIndexOf(']') < 0)
throw new FormatException($"AdGuard upstreams line missing ']': {line}");
} Prevention
- Re-export upstreams files from a known-good AdGuard source.
- Lint '['-prefixed lines to confirm a ']' before the upstream server tokens.
- Prefer the app's native JSON forwarders config over hand-edited AdGuard files.
When it happens
Trigger: An AdGuard upstreams line beginning with '[' but missing the closing ']', e.g. '[/example.com/ 1.1.1.1' or '[]example.com 8.8.8.8' written incorrectly. Any '['-prefixed line without a ']' triggers it.
Common situations: Hand-editing an AdGuard-style upstreams file and dropping the ']' bracket; truncated line from a copy-paste; wrong file format chosen for the upstream source.
Related errors
- Invalid AdGuard Upstreams config file format: missing defaul
- Invalid AdGuard Upstreams config file format: missing upstre
- 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/840ff973bacaea66.
Report an issue: GitHub.