AdguardTeam/AdGuardHome · error
networksetup failed to configure dns servers: %w
Error message
networksetup failed to configure dns servers: %w
What it means
During query-log rotation, the code renames the current log file to its rotated name (e.g. querylog.json to querylog.json.1). os.Rename failed for a reason other than the source not existing (that case is handled gracefully). Typical causes are permission problems or cross-device rename attempts; the error is wrapped with full OS error context.
Source
Thrown at internal/aghnet/net_darwin.go:181
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)
}
return nil
}
// etcResolvConfReg is the regular expression matching the lines of resolv.conf
// file containing a name server information.
var etcResolvConfReg = regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
// getEtcResolvConfServers returns a list of nameservers configured in
// /etc/resolv.conf.
func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)View on GitHub (pinned to b41aefbe51)
Solutions
- Check the wrapped OS error (permission denied, read-only filesystem, etc.) and fix ownership/permissions of the log directory
- Free disk space or remount the filesystem read-write
- Move the log directory onto the same filesystem/device as the target name
- Ensure no backup/AV tool locks the log files during rotation windows
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure directory is writable and on one device before rotation
if fi, err := os.Stat(dir); err != nil || !fi.IsDir() { return err }
if f, err := os.CreateTemp(dir, ""); err != nil { return err } else { f.Close(); os.Remove(f.Name()) } Try / catch
if err := rotate(ctx); err != nil && strings.Contains(err.Error(), "rename old file") {
// log, keep current file (rotation retries next check), alert ops
} Prevention
- Grant write access to the log directory
- Keep log dir and rotated names on the same filesystem
- Monitor disk space and read-only mounts
- Schedule backups outside rotation windows
When it happens
Trigger: Rotation triggered (file exceeded size/time limits) while the process lacks write permission on the log directory, the target file exists and is immutable, or the directory is on a filesystem in a state that blocks renames (read-only mount, disk full on some filesystems).
Common situations: Running the service under a restrictive user after a package update changed ownership; log directory on a read-only or full disk; another process (backup, antivirus) holding the file with a mandatory lock on Windows.
Related errors
- interface %s has no ipv6 addresses
- invalid ip version %d
- could not find hardware port for %s
- networksetup failed to set dns servers: %w
- parsing etc/resolv.conf file: %w
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/55392cc38b8b6586.
Report an issue: GitHub.