{"record":{"id":"6f80b1431d16626f","repo":"TechnitiumSoftware/DnsServer","slug":"maxmind-database-not-initialized-6f80b1","errorCode":null,"errorMessage":"MaxMind database not initialized.","messagePattern":"MaxMind database not initialized\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Apps/GeoContinentApp/CNAME.cs","lineNumber":82,"sourceCode":"        #region public\n\n        public Task InitializeAsync(IDnsServer dnsServer, string? config)\n        {\n            _dnsServer = dnsServer;\n            _maxMind = MaxMind.Create(dnsServer);\n\n            return Task.CompletedTask;\n        }\n\n        public Task<DnsDatagram?> ProcessRequestAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol, bool isRecursionAllowed, string zoneName, string appRecordName, uint appRecordTtl, string appRecordData)\n        {\n            DnsQuestionRecord question = request.Question[0];\n\n            if (!question.Name.Equals(appRecordName, StringComparison.OrdinalIgnoreCase) && !appRecordName.StartsWith('*'))\n                return Task.FromResult<DnsDatagram?>(null);\n\n            if (_maxMind is null)\n                throw new InvalidOperationException(\"MaxMind database not initialized.\");\n\n            using JsonDocument jsonDocument = JsonDocument.Parse(appRecordData, Address._jsonParseOptions);\n            JsonElement jsonAppRecordData = jsonDocument.RootElement;\n            JsonElement jsonContinent = default;\n            string? continentCode = null;\n\n            byte scopePrefixLength = 0;\n            EDnsClientSubnetOptionData requestECS = request.GetEDnsClientSubnetOption();\n            if (requestECS is not null)\n            {\n                long? asn = null;\n\n                if ((_maxMind.IspReader is not null) && _maxMind.IspReader.TryIsp(requestECS.Address, out IspResponse? csIsp) && (csIsp.Network is not null))\n                {\n                    scopePrefixLength = (byte)csIsp.Network.PrefixLength;\n                    asn = csIsp.AutonomousSystemNumber;\n                }\n                else if ((_maxMind.AsnReader is not null) && _maxMind.AsnReader.TryAsn(requestECS.Address, out AsnResponse? csAsn) && (csAsn.Network is not null))","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/GeoContinentApp/CNAME.cs#L64-L100","documentation":"Thrown by GeoContinentApp CNAME.ProcessRequestAsync when _maxMind is null. Identical root cause to error 26 but reached on a CNAME query: the MaxMind reader was never initialised, so continent routing for a CNAME record cannot proceed and raises InvalidOperationException.","triggerScenarios":"A CNAME query hits a GeoContinentApp record while the MaxMind singleton is null — i.e. the underlying country database file was missing at app startup.","commonSituations":"Same as error 26: missing GeoLite2/GeoIP2-Country.mmdb in the application folder, or the file present but unreadable. CNAME-based continent records surface the failure here.","solutions":["Place GeoLite2-Country.mmdb (or GeoIP2-Country.mmdb) in the DNS server ApplicationFolder.","Restart the service so MaxMind construction succeeds.","Confirm by checking that startup no longer logs 'MaxMind Country file is missing!' (error 28)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (_maxMind is null)\n    _log.Warn(\"GeoContinentApp CNAME query for {0} skipped: MaxMind database not loaded.\", appRecordName);","typeGuard":null,"tryCatchPattern":"try { return await ProcessContinentCnameAsync(request, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"MaxMind database not initialized\"))\n{ _log.Error(\"GeoIP country database missing — deploy GeoLite2-Country.mmdb and restart.\"); return Task.FromResult<DnsDatagram?>(null); }","preventionTips":["Ensure the country database is present before serving CNAME continent records.","Fail fast at startup if MaxMind construction throws.","Monitor for the upstream file-missing error (28)."],"tags":["geo","maxmind","config","cname","invalid-operation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}