TechnitiumSoftware/DnsServer · error · InvalidOperationException

MaxMind database not initialized.

Error message

MaxMind database not initialized.

What it means

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.

Source

Thrown at Apps/GeoContinentApp/CNAME.cs:82

        #region public

        public Task InitializeAsync(IDnsServer dnsServer, string? config)
        {
            _dnsServer = dnsServer;
            _maxMind = MaxMind.Create(dnsServer);

            return Task.CompletedTask;
        }

        public Task<DnsDatagram?> ProcessRequestAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol, bool isRecursionAllowed, string zoneName, string appRecordName, uint appRecordTtl, string appRecordData)
        {
            DnsQuestionRecord question = request.Question[0];

            if (!question.Name.Equals(appRecordName, StringComparison.OrdinalIgnoreCase) && !appRecordName.StartsWith('*'))
                return Task.FromResult<DnsDatagram?>(null);

            if (_maxMind is null)
                throw new InvalidOperationException("MaxMind database not initialized.");

            using JsonDocument jsonDocument = JsonDocument.Parse(appRecordData, Address._jsonParseOptions);
            JsonElement jsonAppRecordData = jsonDocument.RootElement;
            JsonElement jsonContinent = default;
            string? continentCode = null;

            byte scopePrefixLength = 0;
            EDnsClientSubnetOptionData requestECS = request.GetEDnsClientSubnetOption();
            if (requestECS is not null)
            {
                long? asn = null;

                if ((_maxMind.IspReader is not null) && _maxMind.IspReader.TryIsp(requestECS.Address, out IspResponse? csIsp) && (csIsp.Network is not null))
                {
                    scopePrefixLength = (byte)csIsp.Network.PrefixLength;
                    asn = csIsp.AutonomousSystemNumber;
                }
                else if ((_maxMind.AsnReader is not null) && _maxMind.AsnReader.TryAsn(requestECS.Address, out AsnResponse? csAsn) && (csAsn.Network is not null))

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Place GeoLite2-Country.mmdb (or GeoIP2-Country.mmdb) in the DNS server ApplicationFolder.
  2. Restart the service so MaxMind construction succeeds.
  3. Confirm by checking that startup no longer logs 'MaxMind Country file is missing!' (error 28).
Defensive patterns

Strategy: try-catch

Validate before calling

if (_maxMind is null)
    _log.Warn("GeoContinentApp CNAME query for {0} skipped: MaxMind database not loaded.", appRecordName);

Try / catch

try { return await ProcessContinentCnameAsync(request, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("MaxMind database not initialized"))
{ _log.Error("GeoIP country database missing — deploy GeoLite2-Country.mmdb and restart."); return Task.FromResult<DnsDatagram?>(null); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/6f80b1431d16626f. Report an issue: GitHub.