{"record":{"id":"19d1321089dc11bf","repo":"thanos-io/thanos","slug":"got-truncated-message-on-tcp-64kib-limit-exceeded","errorCode":null,"errorMessage":"got truncated message on TCP (64kiB limit exceeded?)","messagePattern":"got truncated message on TCP \\(64kiB limit exceeded\\?\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/discovery/dns/miekgdns/lookup.go","lineNumber":145,"sourceCode":"// name (and qtype). Retries with TCP in the event of response truncation,\n// but otherwise just sends back whatever the server gave, whether that be a\n// valid-looking response, or an error.\nfunc askServerForName(name string, qType dns.Type, client *dns.Client, servAddr string, edns bool) (*dns.Msg, error) {\n\tmsg := &dns.Msg{}\n\n\tmsg.SetQuestion(dns.Fqdn(name), uint16(qType))\n\tif edns {\n\t\tmsg.SetEdns0(dns.DefaultMsgSize, false)\n\t}\n\n\tresponse, _, err := client.Exchange(msg, servAddr)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"exchange\")\n\t}\n\n\tif response.Truncated {\n\t\tif client.Net == \"tcp\" {\n\t\t\treturn nil, errors.New(\"got truncated message on TCP (64kiB limit exceeded?)\")\n\t\t}\n\n\t\t// TCP fallback.\n\t\tclient.Net = \"tcp\"\n\t\treturn askServerForName(name, qType, client, servAddr, false)\n\t}\n\n\treturn response, nil\n}\n","sourceCodeStart":127,"sourceCodeEnd":155,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/discovery/dns/miekgdns/lookup.go#L127-L155","documentation":"Raised when a DNS response arrives with the Truncated (TC) bit set even over TCP, where truncation should be impossible under normal conditions (64KiB message limit exceeded). Since TCP was already used as the fallback for UDP truncation, there is no further downgrade and the lookup fails outright.","triggerScenarios":"askServerForName retries over TCP after a truncated UDP reply, but the TCP response is still flagged Truncated — typically a response exceeding the 64KiB DNS message maximum.","commonSituations":"Extremely large SRV record sets (thousands of targets) behind one service name; DNS zone transfer-like responses; misbehaving DNS server setting TC incorrectly; EDNS0 size caps not helping.","solutions":["Reduce the number of records behind the queried name (split the service, shrink the SRV set)","Check whether EDNS0/advertising larger UDP sizes is misconfigured on the server","Inspect the DNS server logs for why it truncates a TCP answer","Use a different resolution mechanism (e.g. smaller record TTLs/trees, or query with a more specific name)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// estimate answer size beforehand\nn, _ := countSRVRecords(name) // if huge, avoid one giant SRV query\nif n > 1000 { /* split queries or use pagination via multiple names */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"truncated message on TCP\") {\n    return fallbackToSmallerQueries(name) // e.g. query subsets of the record set\n}","preventionTips":["Keep SRV/record sets per name small (hundreds, not thousands of targets)","Prefer many smaller service names over one mega-service with huge record sets","Ensure the DNS server supports EDNS0 and large answers correctly","Alert on growing record counts behind discovery targets"],"tags":["dns","truncated-response","tcp"],"backgroundTag":"dns-truncated-response","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}