AdguardTeam/AdGuardHome · error
networksetup failed to set dns servers: %w
Error message
networksetup failed to set dns servers: %w
What it means
newQueryLog validates the configured rotation interval with validateIvl before returning the query log instance; an unsupported interval (wrong units, out of allowed range, or zero/negative) is wrapped as 'unsupported interval'. This fails construction, so query logging cannot start with that config.
Source
Thrown at internal/aghnet/net_darwin.go:165
if err != nil {
return err
}
if portInfo.static {
return errors.Error("ip address is already static")
}
dnsAddrs, err := getEtcResolvConfServers()
if err != nil {
return err
}
args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...)
// Setting DNS servers is necessary when configuring a static IP.
err = executil.RunWithPeek(ctx, cmdCons, aghos.MaxCmdOutputSize, networkSetupCmd, args...)
if err != nil {
return fmt.Errorf("networksetup failed to set dns servers: %w", err)
}
// Actually configures hardware port to have static IP.
err = executil.RunWithPeek(
ctx,
cmdCons,
aghos.MaxCmdOutputSize,
networkSetupCmd,
"-setmanual",
portInfo.name,
portInfo.ip,
portInfo.subnet,
portInfo.gatewayIP,
)
if err != nil {
return fmt.Errorf("networksetup failed to configure dns servers: %w", err)
}
View on GitHub (pinned to b41aefbe51)
Solutions
- Check validateIvl's bounds in internal/querylog/querylog.go and adjust the interval
- Set rotation_interval to a supported positive duration within the allowed range (e.g. 24h or 7d in the UI)
- Regenerate the config programmatically with explicit time.Duration units
- Restart/recreate the query log after fixing the config
Example fix
// before cfg.RotationIvl = 0 // after cfg.RotationIvl = 24 * time.Hour
Defensive patterns
Strategy: validation
Validate before calling
if conf.RotationIvl <= 0 || conf.RotationIvl%time.Minute != 0 {
return fmt.Errorf("bad rotation interval %s", conf.RotationIvl)
} Type guard
func isValidRotationIvl(d time.Duration) bool {
return d > 0 && d%time.Minute == 0
} Try / catch
ql, err := querylog.New(ctx, conf)
if err != nil && strings.Contains(err.Error(), "unsupported interval") {
// default the interval and retry construction
} Prevention
- Always set explicit time.Duration units
- Bound-check generated config values
- Unit-test config generation against validateIvl rules
When it happens
Trigger: Creating a query log (New or in tests) with conf.RotationIvl set to a value validateIvl rejects — e.g. a negative duration, an interval smaller/larger than allowed bounds, or not a whole multiple of supported units.
Common situations: Setting rotation_interval in the config to 0, a negative number, or a fractional/nonstandard unit; upgrading to a version that tightened the allowed interval range; unit mismatch (seconds vs milliseconds) when programmatically generating config.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- interface %s has no ipv6 addresses
- invalid ip version %d
- could not find hardware port for %s
- found no dns servers in %s
- writing conf: %w
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/7ba3e7d71d32ae5c.
Report an issue: GitHub.