TechnitiumSoftware/DnsServer · error · FormatException

Proxy server was not defined: {proxyName}

Error message

Proxy server was not defined: {proxyName}

What it means

Thrown in AdvancedForwardingApp ReloadConfig when the AdGuard upstream JSON block specifies a non-empty 'proxy' name but the proxy is not found in the provided configProxyServers map (or the map is null). FormatException is raised during config reload.

Source

Thrown at Apps/AdvancedForwardingApp/App.cs:741

                    line = line.Substring(i + 1);
                }

                return word;
            }

            #endregion

            #region public

            public void ReloadConfig(Dictionary<string, ConfigProxyServer>? configProxyServers, JsonElement jsonAdguardUpstream)
            {
                string? proxyName = jsonAdguardUpstream.GetPropertyValue("proxy", null);
                _dnssecValidation = jsonAdguardUpstream.GetPropertyValue("dnssecValidation", true);

                ConfigProxyServer? configProxyServer = null;

                if (!string.IsNullOrEmpty(proxyName) && ((configProxyServers is null) || !configProxyServers.TryGetValue(proxyName, out configProxyServer)))
                    throw new FormatException("Proxy server was not defined: " + proxyName);

                _configProxyServer = configProxyServer;

                DateTime configFileLastModified = File.GetLastWriteTimeUtc(_configFile);
                if (configFileLastModified > _configFileLastModified)
                {
                    //reload complete config file
                    _autoReloadTimer?.Change(0, Timeout.Infinite);
                }
                else
                {
                    //update only forwarder records
                    _defaultForwarderRecords = GetUpdatedForwarderRecords(_defaultForwarderRecords ?? [], _dnssecValidation, _configProxyServer);

                    foreach (Forwarding forwarding in _forwardings ?? [])
                        forwarding.UpdateForwarderRecords(_dnssecValidation, _configProxyServer);
                }
            }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Add or correct a proxy server entry with the matching name in the AdvancedForwardingApp proxy servers configuration.
  2. Remove the 'proxy' property (or set it empty) if no proxy is intended for that upstream.
  3. When renaming a proxy, update every AdGuard upstream and forwarder that references it.

Example fix

// before (dnsApp.config)
"proxyServers": { "socksA": { ... } },
"adGuardUpstream": { "proxy": "socksB" }
// after
"adGuardUpstream": { "proxy": "socksA" }
Defensive patterns

Strategy: validation

Validate before calling

string? proxyName = jsonAdguardUpstream.GetPropertyValue("proxy", null);
if (!string.IsNullOrEmpty(proxyName) && (configProxyServers is null || !configProxyServers.ContainsKey(proxyName)))
    throw new FormatException($"AdGuard upstream references undefined proxy '{proxyName}'.");

Type guard

static bool IsProxyDefined(string? name, Dictionary<string, ConfigProxyServer>? map) => string.IsNullOrEmpty(name) || (map is not null && map.ContainsKey(name!));

Prevention

When it happens

Trigger: The AdGuard upstream config object has "proxy": "someName" but no proxy server with that name was declared in the app's top-level proxy servers configuration, so TryGetValue fails.

Common situations: Typo in the proxy name; deleting/renaming a proxy server while an upstream still references it; referencing a proxy from a different app's config.

Related errors


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