{"record":{"id":"f03d051a9fc5aa33","repo":"coredns/coredns","slug":"num-sockets-can-not-be-zero-or-negative-d","errorCode":null,"errorMessage":"num sockets can not be zero or negative: %d","messagePattern":"num sockets can not be zero or negative: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/multisocket/multisocket.go","lineNumber":47,"sourceCode":"\n\targs := c.RemainingArgs()\n\n\tif len(args) > 1 || c.Next() {\n\t\treturn c.ArgErr()\n\t}\n\n\tif len(args) == 0 {\n\t\t// Nothing specified; use default that is equal to GOMAXPROCS.\n\t\tconfig.NumSockets = runtime.GOMAXPROCS(0)\n\t\treturn nil\n\t}\n\n\tnumSockets, err := strconv.Atoi(args[0])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid num sockets: %w\", err)\n\t}\n\tif numSockets < 1 {\n\t\treturn fmt.Errorf(\"num sockets can not be zero or negative: %d\", numSockets)\n\t}\n\tif numSockets > maxNumSockets {\n\t\treturn fmt.Errorf(\"num sockets exceeds maximum (%d): %d\", maxNumSockets, numSockets)\n\t}\n\tconfig.NumSockets = numSockets\n\n\treturn nil\n}\n","sourceCodeStart":29,"sourceCodeEnd":56,"githubUrl":"https://github.com/coredns/coredns/blob/558c9757a92b361e550bdba82d0b4ddf3d12d595/plugin/multisocket/multisocket.go#L29-L56","documentation":"multisocket's parseNumSockets rejects socket counts below 1. The plugin binds one UDP/TCP socket per configured count, so zero or negative values are meaningless and are rejected with this error during Corefile setup.","triggerScenarios":"Corefile directive like `multisocket 0` or `multisocket -2` is parsed by parseNumSockets (called from setup at plugin load).","commonSituations":"Attempting to 'disable' multisocket by setting 0 instead of removing the directive; templated configs computing a count from CPU metrics that yields 0.","solutions":["Set the directive to a positive integer, e.g. `multisocket 4`","Remove the multisocket directive if you want single-socket default behavior","Fix the template/script that generated the count so it clamps to at least 1"],"exampleFix":"// before\nmultisocket 0\n// after\nmultisocket 1","handlingStrategy":"validation","validationCode":"n, err := strconv.Atoi(value); if err == nil && n < 1 { return errors.New(\"num sockets must be >= 1\") }","typeGuard":null,"tryCatchPattern":"if err := setup(...); err != nil && strings.Contains(err.Error(), \"zero or negative\") { /* clamp or remove directive */ }","preventionTips":["Never use 0 to 'disable' multisocket — remove the directive instead","Clamp computed counts to a minimum of 1 in generated configs","Document the >= 1 constraint in config templates"],"tags":["coredns","corefile","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"558c9757a92b361e550bdba82d0b4ddf3d12d595","analyzedAt":"2026-09-06T22:47:02.106Z","contentChangedAt":"2026-09-06T22:47:02.106Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}