TechnitiumSoftware/DnsServer · error · InvalidOperationException
MaxMind database not initialized.
Error message
MaxMind database not initialized.
What it means
Thrown by GeoDistanceApp CNAME.ProcessRequestAsync when _maxMind is null. CNAME counterpart of error 32: without a MaxMind reader the distance calculation cannot run and the lookup raises InvalidOperationException.
Source
Thrown at Apps/GeoDistanceApp/CNAME.cs:99
#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.");
Location? location = null;
byte scopePrefixLength = 0;
EDnsClientSubnetOptionData requestECS = request.GetEDnsClientSubnetOption();
if (requestECS is not 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;
else if ((_maxMind.AsnReader is not null) && _maxMind.AsnReader.TryAsn(requestECS.Address, out AsnResponse? csAsn) && (csAsn.Network is not null))
scopePrefixLength = (byte)csAsn.Network.PrefixLength;
else
scopePrefixLength = requestECS.SourcePrefixLength;
if (_maxMind.CityReader.TryCity(requestECS.Address, out CityResponse? csResponse) && csResponse.Location.HasCoordinates)
location = csResponse.Location;
}
View on GitHub (pinned to d0484b6c1e)
Solutions
- Place GeoLite2-City.mmdb (or GeoIP2-City.mmdb) in the ApplicationFolder.
- Restart the service so the MaxMind constructor initialises _maxMind.
- Verify error 34 does not reappear at startup.
Defensive patterns
Strategy: try-catch
Validate before calling
if (_maxMind is null)
_log.Warn("GeoDistanceApp CNAME query for {0} skipped: MaxMind City database not loaded.", appRecordName); Try / catch
try { return await ProcessDistanceCnameAsync(request, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("MaxMind database not initialized"))
{ _log.Error("GeoIP City database missing — deploy GeoLite2-City.mmdb."); return Task.FromResult<DnsDatagram?>(null); } Prevention
- Ensure the City database is present before serving CNAME distance records.
- Track error 34 in startup diagnostics.
- Add a readiness check on _maxMind.
When it happens
Trigger: A CNAME query matches a GeoDistanceApp record while _maxMind is null, i.e. the City database file was missing at startup.
Common situations: City database not deployed or removed; CNAME distance records then fail.
Related errors
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind database not initialized.
- MaxMind database not initialized.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/a4c840ba0066d6c3.
Report an issue: GitHub.