coredns/coredns · error
num sockets can not be zero or negative: %d
Error message
num sockets can not be zero or negative: %d
What it means
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.
Source
Thrown at plugin/multisocket/multisocket.go:47
args := c.RemainingArgs()
if len(args) > 1 || c.Next() {
return c.ArgErr()
}
if len(args) == 0 {
// Nothing specified; use default that is equal to GOMAXPROCS.
config.NumSockets = runtime.GOMAXPROCS(0)
return nil
}
numSockets, err := strconv.Atoi(args[0])
if err != nil {
return fmt.Errorf("invalid num sockets: %w", err)
}
if numSockets < 1 {
return fmt.Errorf("num sockets can not be zero or negative: %d", numSockets)
}
if numSockets > maxNumSockets {
return fmt.Errorf("num sockets exceeds maximum (%d): %d", maxNumSockets, numSockets)
}
config.NumSockets = numSockets
return nil
}
View on GitHub (pinned to 558c9757a9)
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
Example fix
// before multisocket 0 // after multisocket 1
Defensive patterns
Strategy: validation
Validate before calling
n, err := strconv.Atoi(value); if err == nil && n < 1 { return errors.New("num sockets must be >= 1") } Try / catch
if err := setup(...); err != nil && strings.Contains(err.Error(), "zero or negative") { /* clamp or remove directive */ } Prevention
- 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
When it happens
Trigger: Corefile directive like `multisocket 0` or `multisocket -2` is parsed by parseNumSockets (called from setup at plugin load).
Common situations: Attempting to 'disable' multisocket by setting 0 instead of removing the directive; templated configs computing a count from CPU metrics that yields 0.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- reload duration value is expected
- at least one address or interface name is expected
- at least one address or interface must be given to except su
- cache TTL can not be zero or negative: %d
- prefetch amount should be positive: %d
AI-assisted analysis of coredns/coredns@558c9757a9 (2026-09-06).
Data as JSON: /api/errors/f03d051a9fc5aa33.
Report an issue: GitHub.