{"record":{"id":"74bc5d46810b56eb","repo":"TechnitiumSoftware/DnsServer","slug":"failed-to-resync-configuration-the-cluster-is-not","errorCode":null,"errorMessage":"Failed to resync configuration: the Cluster is not initialized.","messagePattern":"Failed to resync configuration: the Cluster is not initialized\\.","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"warning","filePath":"DnsServerCore/Cluster/ClusterManager.cs","lineNumber":1622,"sourceCode":"        public void TriggerRefreshForConfig(IReadOnlyCollection<string> configRefreshIncludeZones = null)\n        {\n            //do validation\n            if (!ClusterInitialized)\n                throw new DnsServerException(\"Failed to refresh configuration: the Cluster is not initialized.\");\n\n            ClusterNode primaryNode = GetPrimaryNode();\n\n            if (primaryNode.State == ClusterNodeState.Self)\n                throw new DnsServerException(\"Failed to refresh configuration: only Secondary nodes can sync configuration from Primary nodes.\");\n\n            TriggerRefreshForConfig(CONFIG_REFRESH_TIMER_INTERVAL, configRefreshIncludeZones);\n        }\n\n        public void TriggerResyncForConfig()\n        {\n            //do validation\n            if (!ClusterInitialized)\n                throw new DnsServerException(\"Failed to resync configuration: the Cluster is not initialized.\");\n\n            ClusterNode primaryNode = GetPrimaryNode();\n\n            if (primaryNode.State == ClusterNodeState.Self)\n                throw new DnsServerException(\"Failed to resync configuration: only Secondary nodes can sync configuration from Primary nodes.\");\n\n            _configLastSynced = DateTime.UnixEpoch; //to ensure complete config resync\n\n            //trigger immediate config refresh\n            TriggerRefreshForConfig(0);\n        }\n\n        private void TriggerRefreshForConfig(int refreshInterval, IReadOnlyCollection<string> configRefreshIncludeZones = null)\n        {\n            _configRefreshLock.Wait();\n            try\n            {\n                if (configRefreshIncludeZones is not null)","sourceCodeStart":1604,"sourceCodeEnd":1640,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Cluster/ClusterManager.cs#L1604-L1640","documentation":"Thrown at the top of TriggerResyncForConfig when ClusterInitialized is false. Resync forces a complete config pull (it resets _configLastSynced to UnixEpoch) from the primary, so it needs an active cluster; a standalone node cannot resync.","triggerScenarios":"Calling TriggerResyncForConfig (the 'force full resync' action) on a server that is not clustered.","commonSituations":"Operator clicked 'resync configuration' on a standalone primary; the node already left the cluster; cluster state file missing so _clusterNodes is empty.","solutions":["Guard with ClusterInitialized; report 'not clustered' instead of calling resync.","If clustering is intended, run JoinClusterAsync first to establish the primary relationship, then resync.","Make the resync control unavailable unless the node is a clustered secondary."],"exampleFix":"// before\nclusterManager.TriggerResyncForConfig();\n\n// after\nif (!clusterManager.ClusterInitialized)\n    return BadRequest(\"Not clustered; cannot resync.\");\nclusterManager.TriggerResyncForConfig();","handlingStrategy":"validation","validationCode":"if (!clusterManager.ClusterInitialized)\n    return BadRequest(\"Not clustered; cannot resync.\");\nclusterManager.TriggerResyncForConfig();","typeGuard":"static bool CanResyncConfig(ClusterManager cm) => cm.ClusterInitialized;","tryCatchPattern":"try { clusterManager.TriggerResyncForConfig(); }\ncatch (DnsServerException ex) when (ex.Message.Contains(\"not initialized\"))\n{ /* not clustered; no-op */ }","preventionTips":["Gate resync on ClusterInitialized.","Run resync only from secondary nodes against a reachable primary.","Avoid offering resync on a standalone node in the UI."],"tags":["cluster","precondition","config-resync","technitium","state-guard"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}