TechnitiumSoftware/DnsServer · error · InvalidOperationException
MaxMind database not initialized.
Error message
MaxMind database not initialized.
What it means
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.
Source
Thrown at Apps/GeoCountryApp/Address.cs:170
else
{
_groups = new Dictionary<string, List<string>>();
}
}
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);
switch (question.Type)
{
case DnsResourceRecordType.A:
case DnsResourceRecordType.AAAA:
if (_maxMind is null)
throw new InvalidOperationException("MaxMind database not initialized.");
using (JsonDocument jsonDocument = JsonDocument.Parse(appRecordData, _jsonParseOptions))
{
JsonElement jsonAppRecordData = jsonDocument.RootElement;
JsonElement jsonCountry = default;
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
- 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).
Defensive patterns
Strategy: try-catch
Validate before calling
if (_maxMind is null)
_log.Warn("GeoCountryApp A/AAAA query for {0} skipped: MaxMind database not loaded.", appRecordName); Try / catch
try { return await ProcessCountryAsync(request, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("MaxMind database not initialized"))
{ _log.Error("GeoIP country database missing — deploy GeoLite2-Country.mmdb."); return Task.FromResult<DnsDatagram?>(null); } Prevention
- 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.
When it happens
Trigger: A DNS A/AAAA query matches a GeoCountryApp record, but the GeoLite2/GeoIP2-Country.mmdb file was missing at startup, leaving _maxMind null.
Common situations: GeoCountryApp configured without deploying the MaxMind country database, or the database removed after initial setup. Country-based answers fail for every client.
Related errors
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind Country file is missing!
- MaxMind Country file is missing!
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/b88605cfb8863900.
Report an issue: GitHub.