{"record":{"id":"b8db0bc1da83fd7e","repo":"coredns/coredns","slug":"more-than-d-tos-configured-d","errorCode":null,"errorMessage":"more than %d TOs configured: %d","messagePattern":"more than (.+?) TOs configured: (.+?)","errorType":"validation","errorClass":"plugin.Error","httpStatus":null,"severity":"error","filePath":"plugin/forward/setup.go","lineNumber":38,"sourceCode":"\tpkgtls \"github.com/coredns/coredns/plugin/pkg/tls\"\n\t\"github.com/coredns/coredns/plugin/pkg/transport\"\n\n\t\"github.com/miekg/dns\"\n)\n\nfunc init() {\n\tplugin.Register(\"forward\", setup)\n}\n\nfunc setup(c *caddy.Controller) error {\n\tfs, err := parseForward(c)\n\tif err != nil {\n\t\treturn plugin.Error(\"forward\", err)\n\t}\n\tfor i := range fs {\n\t\tf := fs[i]\n\t\tif len(f.toEntries) > max {\n\t\t\treturn plugin.Error(\"forward\", fmt.Errorf(\"more than %d TOs configured: %d\", max, len(f.toEntries)))\n\t\t}\n\n\t\tif i == len(fs)-1 {\n\t\t\t// last forward: point next to next plugin\n\t\t\tdnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {\n\t\t\t\tf.Next = next\n\t\t\t\treturn f\n\t\t\t})\n\t\t} else {\n\t\t\t// middle forward: point next to next forward\n\t\t\tnextForward := fs[i+1]\n\t\t\tdnsserver.GetConfig(c).AddPlugin(func(plugin.Handler) plugin.Handler {\n\t\t\t\tf.Next = nextForward\n\t\t\t\treturn f\n\t\t\t})\n\t\t}\n\n\t\tc.OnStartup(func() error {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/coredns/coredns/blob/558c9757a92b361e550bdba82d0b4ddf3d12d595/plugin/forward/setup.go#L20-L56","documentation":"The forward plugin caps the number of upstream (TO) addresses per forward stanza at max (len of f.toEntries). During setup, if a stanza lists more TO addresses than allowed, setup returns this error and CoreDNS fails to load the plugin. It is a hard configuration limit, not a runtime condition.","triggerScenarios":"A Corefile forward stanza (or one produced by parseForward) listing more than max upstream addresses, e.g. 'forward . 1.1.1.1 8.8.8.8 ...' exceeding the cap; exercised in TestMultiForward/TestSetTapPlugin.","commonSituations":"Copy-pasting a long list of public resolvers into one forward stanza; generated configs enumerating many upstreams; older deployments migrated to a version with a stricter cap.","solutions":["Reduce the number of TO addresses in the forward stanza to at most the allowed maximum.","Split upstreams across multiple forward stanzas with different zones (policy is per-stanza anyway).","Place a local load balancer (or dnsmasq/service VIP) in front of many upstreams and forward to that single address."],"exampleFix":"// before\nforward . 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 9.9.9.9 149.112.112.112 208.67.222.222 208.67.220.220\n// after (one stanza per zone or trimmed list)\nforward . 8.8.8.8 1.1.1.1 9.9.9.9","handlingStrategy":"validation","validationCode":"if len(toAddresses) > maxAllowedTOs {\n    return fmt.Errorf(\"too many upstreams: %d\", len(toAddresses))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep forward TO lists small (2-3 upstreams).","Front large upstream pools with a load balancer VIP.","Validate Corefile with coredns -conf in CI."],"tags":["configuration","forward-plugin","limit-exceeded","coredns"],"backgroundTag":"value-out-of-range","analyzedSha":"558c9757a92b361e550bdba82d0b4ddf3d12d595","analyzedAt":"2026-09-06T22:47:02.106Z","contentChangedAt":"2026-09-06T22:47:02.106Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}