{"record":{"id":"55392cc38b8b6586","repo":"AdguardTeam/AdGuardHome","slug":"networksetup-failed-to-configure-dns-servers-w","errorCode":null,"errorMessage":"networksetup failed to configure dns servers: %w","messagePattern":"networksetup failed to configure dns servers: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghnet/net_darwin.go","lineNumber":181,"sourceCode":"\terr = executil.RunWithPeek(ctx, cmdCons, aghos.MaxCmdOutputSize, networkSetupCmd, args...)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"networksetup failed to set dns servers: %w\", err)\n\t}\n\n\t// Actually configures hardware port to have static IP.\n\terr = executil.RunWithPeek(\n\t\tctx,\n\t\tcmdCons,\n\t\taghos.MaxCmdOutputSize,\n\t\tnetworkSetupCmd,\n\t\t\"-setmanual\",\n\t\tportInfo.name,\n\t\tportInfo.ip,\n\t\tportInfo.subnet,\n\t\tportInfo.gatewayIP,\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"networksetup failed to configure dns servers: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// etcResolvConfReg is the regular expression matching the lines of resolv.conf\n// file containing a name server information.\nvar etcResolvConfReg = regexp.MustCompile(\"nameserver ([a-zA-Z0-9.:]+)\")\n\n// getEtcResolvConfServers returns a list of nameservers configured in\n// /etc/resolv.conf.\nfunc getEtcResolvConfServers() (addrs []string, err error) {\n\tconst filename = \"etc/resolv.conf\"\n\n\t_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {\n\t\tsc := bufio.NewScanner(r)\n\t\tfor sc.Scan() {\n\t\t\tmatches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghnet/net_darwin.go#L163-L199","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure directory is writable and on one device before rotation\nif fi, err := os.Stat(dir); err != nil || !fi.IsDir() { return err }\nif f, err := os.CreateTemp(dir, \"\"); err != nil { return err } else { f.Close(); os.Remove(f.Name()) }","typeGuard":null,"tryCatchPattern":"if err := rotate(ctx); err != nil && strings.Contains(err.Error(), \"rename old file\") {\n    // log, keep current file (rotation retries next check), alert ops\n}","preventionTips":["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"],"tags":["querylog","file-rotation","filesystem","permissions","go"],"backgroundTag":"file-rename-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}