TechnitiumSoftware/DnsServer · warning · DnsServerException

Cannot set records. Please try again.

Error message

Cannot set records. Please try again.

What it means

Thrown by PrimaryZone.SetRecords() in the default branch when TrySetRecords for the requested record type returns false. The TTL and type checks already passed, so this is a record-store-layer failure to commit the new RRset. The message asks to retry, signalling a transient rather than permanent condition.

Source

Thrown at DnsServerCore/Dns/Zones/PrimaryZone.cs:2608

                    TriggerNotify();
                    break;

                case DnsResourceRecordType.DNSKEY:
                case DnsResourceRecordType.RRSIG:
                case DnsResourceRecordType.NSEC:
                case DnsResourceRecordType.NSEC3PARAM:
                case DnsResourceRecordType.NSEC3:
                    throw new InvalidOperationException("Cannot set DNSSEC records.");

                case DnsResourceRecordType.FWD:
                    throw new DnsServerException("The record type is not supported by primary zones.");

                default:
                    if (records[0].OriginalTtlValue > GetZoneSoaExpire())
                        throw new DnsServerException("Cannot set records: TTL cannot be greater than SOA EXPIRE.");

                    if (!TrySetRecords(type, records, out IReadOnlyList<DnsResourceRecord> deletedRecords))
                        throw new DnsServerException("Cannot set records. Please try again.");

                    CommitAndIncrementSerial(deletedRecords, records);

                    if (_dnssecStatus != AuthZoneDnssecStatus.Unsigned)
                        UpdateDnssecRecordsFor(this, type);

                    TriggerNotify();
                    break;
            }
        }

        public override bool AddRecord(DnsResourceRecord record)
        {
            if (_dnssecStatus != AuthZoneDnssecStatus.Unsigned)
            {
                switch (record.Type)
                {
                    case DnsResourceRecordType.ANAME:

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Retry SetRecords after a short backoff; the message indicates a transient failure.
  2. Serialize record mutations for a given zone to avoid concurrent TrySetRecords contention.
  3. If retries persistently fail, check the server log for the underlying store/IO error reported by TrySetRecords.

Example fix

// before
zone.SetRecords(type, records);

// after
for (int attempt = 0; ; attempt++)
{
    try { zone.SetRecords(type, records); break; }
    catch (DnsServerException) when (attempt < 2) { Thread.Sleep(Backoff(attempt)); }
}
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

for (int attempt = 0; attempt < 3; attempt++)
{
    try { zone.SetRecords(type, records); return; }
    catch (DnsServerException ex) when (ex.Message == "Cannot set records. Please try again." && attempt < 2)
    { Thread.Sleep(TimeSpan.FromSeconds(1 << attempt)); }
}

Prevention

When it happens

Trigger: TrySetRecords(type, records, out deletedRecords) returns false while replacing a normal RRset. Typically concurrent modification, a transient store/IO error, or an inability to commit atomically.

Common situations: Concurrent record writers (other API calls, replication, notify) mutating the zone; backing store temporarily locked or low on resources; race between zone flush and record update.

Related errors


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