{"record":{"id":"b88605cfb8863900","repo":"TechnitiumSoftware/DnsServer","slug":"maxmind-database-not-initialized-b88605","errorCode":null,"errorMessage":"MaxMind database not initialized.","messagePattern":"MaxMind database not initialized\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Apps/GeoCountryApp/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 jsonCountry = 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/GeoCountryApp/Address.cs#L152-L188","documentation":"Thrown by GeoCountryApp Address.ProcessRequestAsync in the A/AAAA branch when _maxMind is null. Functionally identical to error 26 but for country-level geo routing: the MaxMind reader was not built at startup (see error 31), so a country lookup cannot run and raises InvalidOperationException.","triggerScenarios":"A DNS A/AAAA query matches a GeoCountryApp record, but the GeoLite2/GeoIP2-Country.mmdb file was missing at startup, leaving _maxMind null.","commonSituations":"GeoCountryApp configured without deploying the MaxMind country database, or the database removed after initial setup. Country-based answers fail for every client.","solutions":["Deploy GeoLite2-Country.mmdb (or GeoIP2-Country.mmdb) into the ApplicationFolder.","Restart the DnsServer service so the GeoCountryApp MaxMind constructor succeeds.","Verify startup log shows no 'MaxMind Country file is missing!' (error 31)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (_maxMind is null)\n    _log.Warn(\"GeoCountryApp A/AAAA query for {0} skipped: MaxMind database not loaded.\", appRecordName);","typeGuard":null,"tryCatchPattern":"try { return await ProcessCountryAsync(request, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"MaxMind database not initialized\"))\n{ _log.Error(\"GeoIP country database missing — deploy GeoLite2-Country.mmdb.\"); return Task.FromResult<DnsDatagram?>(null); }","preventionTips":["Deploy GeoLite2-Country.mmdb before enabling GeoCountryApp.","Fail fast at startup if the MaxMind reader is null.","Watch for the upstream error 31 in startup logs."],"tags":["geo","maxmind","country","config","invalid-operation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}