{"record":{"id":"7d3e48dcd2a9860d","repo":"TechnitiumSoftware/DnsServer","slug":"maxmind-database-not-initialized","errorCode":null,"errorMessage":"MaxMind database not initialized.","messagePattern":"MaxMind database not initialized\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Apps/GeoContinentApp/Address.cs","lineNumber":170,"sourceCode":"            else\n            {\n                _groups = new Dictionary<string, List<string>>();\n            }\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            switch (question.Type)\n            {\n                case DnsResourceRecordType.A:\n                case DnsResourceRecordType.AAAA:\n                    if (_maxMind is null)\n                        throw new InvalidOperationException(\"MaxMind database not initialized.\");\n\n                    using (JsonDocument jsonDocument = JsonDocument.Parse(appRecordData, _jsonParseOptions))\n                    {\n                        JsonElement jsonAppRecordData = jsonDocument.RootElement;\n                        JsonElement jsonContinent = default;\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":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/Apps/GeoContinentApp/Address.cs#L152-L188","documentation":"Thrown by GeoContinentApp Address.ProcessRequestAsync in the A/AAAA branch when the _maxMind singleton is null. The app lazily relies on a MaxMind database reader that is constructed during app initialisation; if construction failed (file missing, see error 28) the field stays null and any geo lookup raises InvalidOperationException.","triggerScenarios":"A DNS A/AAAA query matches a GeoContinentApp record, but the MaxMind instance was never created — typically because the GeoLite2-Country.mmdb / GeoIP2-Country.mmdb file was absent at startup, so the MaxMind constructor threw and _maxMind remained null.","commonSituations":"Fresh install without the GeoIP database files deployed, files moved or renamed, or the application folder changed. The symptom is that continent-based answers never work.","solutions":["Download GeoLite2-Country.mmdb (or GeoIP2-Country.mmdb) from MaxMind and place it in the DNS server ApplicationFolder.","Restart the DnsServer service so the GeoContinentApp MaxMind constructor succeeds and _maxMind is populated.","Check the startup log for the companion error 'MaxMind Country file is missing!' (error 28) to confirm the root cause."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (_maxMind is null)\n    _log.Warn(\"GeoContinentApp A/AAAA query for {0} skipped: MaxMind database not loaded (place GeoLite2-Country.mmdb in the application folder).\", appRecordName);","typeGuard":null,"tryCatchPattern":"try { return await ProcessContinentAsync(request, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"MaxMind database not initialized\"))\n{ _log.Error(\"GeoIP database missing — see error 'MaxMind Country file is missing!'\"); return Task.FromResult<DnsDatagram?>(null); }","preventionTips":["Deploy GeoLite2-Country.mmdb before enabling GeoContinentApp.","Add a startup health check that fails fast if _maxMind is null.","Surface the upstream FileNotFoundException (error 28) in operator dashboards."],"tags":["geo","maxmind","config","invalid-operation","runtime-state"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}