{"record":{"id":"6f153b0470f5d44a","repo":"TechnitiumSoftware/DnsServer","slug":"proxy-server-was-not-defined-proxyname","errorCode":null,"errorMessage":"Proxy server was not defined: {proxyName}","messagePattern":"Proxy server was not defined: (.+?)","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"Apps/AdvancedForwardingApp/App.cs","lineNumber":741,"sourceCode":"                    line = line.Substring(i + 1);\n                }\n\n                return word;\n            }\n\n            #endregion\n\n            #region public\n\n            public void ReloadConfig(Dictionary<string, ConfigProxyServer>? configProxyServers, JsonElement jsonAdguardUpstream)\n            {\n                string? proxyName = jsonAdguardUpstream.GetPropertyValue(\"proxy\", null);\n                _dnssecValidation = jsonAdguardUpstream.GetPropertyValue(\"dnssecValidation\", true);\n\n                ConfigProxyServer? configProxyServer = null;\n\n                if (!string.IsNullOrEmpty(proxyName) && ((configProxyServers is null) || !configProxyServers.TryGetValue(proxyName, out configProxyServer)))\n                    throw new FormatException(\"Proxy server was not defined: \" + proxyName);\n\n                _configProxyServer = configProxyServer;\n\n                DateTime configFileLastModified = File.GetLastWriteTimeUtc(_configFile);\n                if (configFileLastModified > _configFileLastModified)\n                {\n                    //reload complete config file\n                    _autoReloadTimer?.Change(0, Timeout.Infinite);\n                }\n                else\n                {\n                    //update only forwarder records\n                    _defaultForwarderRecords = GetUpdatedForwarderRecords(_defaultForwarderRecords ?? [], _dnssecValidation, _configProxyServer);\n\n                    foreach (Forwarding forwarding in _forwardings ?? [])\n                        forwarding.UpdateForwarderRecords(_dnssecValidation, _configProxyServer);\n                }\n            }","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/AdvancedForwardingApp/App.cs#L723-L759","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add or correct a proxy server entry with the matching name in the AdvancedForwardingApp proxy servers configuration.","Remove the 'proxy' property (or set it empty) if no proxy is intended for that upstream.","When renaming a proxy, update every AdGuard upstream and forwarder that references it."],"exampleFix":"// before (dnsApp.config)\n\"proxyServers\": { \"socksA\": { ... } },\n\"adGuardUpstream\": { \"proxy\": \"socksB\" }\n// after\n\"adGuardUpstream\": { \"proxy\": \"socksA\" }","handlingStrategy":"validation","validationCode":"string? proxyName = jsonAdguardUpstream.GetPropertyValue(\"proxy\", null);\nif (!string.IsNullOrEmpty(proxyName) && (configProxyServers is null || !configProxyServers.ContainsKey(proxyName)))\n    throw new FormatException($\"AdGuard upstream references undefined proxy '{proxyName}'.\");","typeGuard":"static bool IsProxyDefined(string? name, Dictionary<string, ConfigProxyServer>? map) => string.IsNullOrEmpty(name) || (map is not null && map.ContainsKey(name!));","tryCatchPattern":null,"preventionTips":["Declare proxy servers in the app config before referencing them.","Leave 'proxy' empty for direct connections.","Update all references when renaming a proxy."],"tags":["csharp","config","json","proxy","reference","technitium","advanced-forwarding-app"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}