TechnitiumSoftware/DnsServer · error · InvalidOperationException
MaxMind database not initialized.
Error message
MaxMind database not initialized.
What it means
Thrown by GeoCountryApp CNAME.ProcessRequestAsync when _maxMind is null. Same root cause as error 29 but reached on a CNAME query against a country-routed record: no MaxMind reader is available, so the lookup fails with InvalidOperationException.
Source
Thrown at Apps/GeoCountryApp/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 jsonCountry = default;
string? countryCode = 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
- Put GeoLite2-Country.mmdb (or GeoIP2-Country.mmdb) in the ApplicationFolder.
- Restart the service so the MaxMind constructor initialises _maxMind.
- Confirm error 31 no longer appears at startup.
Defensive patterns
Strategy: try-catch
Validate before calling
if (_maxMind is null)
_log.Warn("GeoCountryApp CNAME query for {0} skipped: MaxMind database not loaded.", appRecordName); Try / catch
try { return await ProcessCountryCnameAsync(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
- Ensure the country database is present before serving CNAME country records.
- Surface error 31 in operator tooling.
- Add a startup readiness gate on _maxMind.
When it happens
Trigger: A CNAME query matches a GeoCountryApp record while _maxMind is null, i.e. the country database file was absent at startup.
Common situations: Country database not deployed, moved, or deleted; CNAME country records then surface the failure.
Related errors
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind Country file is missing!
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/4baa4c2b56e18602.
Report an issue: GitHub.