AdguardTeam/AdGuardHome · error
init querylog: %w
Error message
init querylog: %w
What it means
AdGuard Home fails to initialize its DNS query log module. The querylog.New constructor validates configuration (storage paths, ignored-domain engine wiring) and returns an error when the config is invalid or the log storage cannot be created. This happens during DNS module startup, before the server starts listening.
Source
Thrown at internal/home/dns.go:102
HTTPReg: httpReg,
FindClient: globalContext.clients.findMultiple,
BaseDir: querylogDir,
AnonymizeClientIP: config.DNS.AnonymizeClientIP,
RotationIvl: time.Duration(config.QueryLog.Interval),
MemSize: config.QueryLog.MemSize,
Enabled: config.QueryLog.Enabled,
FileEnabled: config.QueryLog.FileEnabled,
}
engine, err = aghnet.NewIgnoreEngine(config.QueryLog.Ignored, config.QueryLog.IgnoredEnabled)
if err != nil {
return fmt.Errorf("querylog: ignored list: %w", err)
}
conf.Ignored = engine
globalContext.queryLog, err = querylog.New(conf)
if err != nil {
return fmt.Errorf("init querylog: %w", err)
}
globalContext.filters, err = filtering.New(config.Filtering, nil)
if err != nil {
// Don't wrap the error, since it's informative enough as is.
return err
}
params := dnsforward.DNSCreateParams{
Logger: baseLogger,
DNSFilter: globalContext.filters,
Stats: globalContext.stats,
QueryLog: globalContext.queryLog,
PrivateNets: parseSubnetSet(config.DNS.PrivateNets),
Anonymizer: anonymizer,
DHCPServer: globalContext.dhcpServer,
EtcHosts: hc,
LocalDomain: config.DHCP.LocalDomainName,View on GitHub (pinned to b41aefbe51)
Solutions
- Check that the data/work directory exists and is writable by the AdGuard Home process user
- Inspect the full wrapped error (%w) — the underlying querylog error names the exact invalid field
- Validate or regenerate the querylog section of the YAML config
- Re-run with a clean data directory to rule out corrupted querylog storage
Example fix
# before
globalContext.queryLog, err = querylog.New(conf)
# after
globalContext.queryLog, err = querylog.New(conf)
if err != nil {
return fmt.Errorf("init querylog: %w", err)
}
// ensure conf.FileBase points to a writable directory, e.g. /opt/AdGuardHome/data/querylog.json Defensive patterns
Strategy: validation
Validate before calling
// Go: pre-validate querylog config before initDNS
if conf.FileBase != "" {
if err := os.MkdirAll(filepath.Dir(conf.FileBase), 0o755); err != nil {
return fmt.Errorf("querylog dir: %w", err)
}
if f, err := os.OpenFile(conf.FileBase, os.O_CREATE|os.O_WRONLY, 0o644); err != nil {
return fmt.Errorf("querylog file unwritable: %w", err)
} else { f.Close() }
} Try / catch
// at startup wrapper
if err := initDNS(ctx, params); err != nil {
if strings.Contains(err.Error(), "init querylog") {
log.Error("querylog init failed; check data dir permissions", slogutil.KeyError, err)
}
return err
} Prevention
- Run AdGuard Home under a dedicated user with write access to its data directory
- Mount the data dir on writable persistent storage in containers
- Validate config.yaml with the AdGuard Home config check before deploying
When it happens
Trigger: Calling initDNS with a querylog configuration that fails validation in querylog.New: invalid file-base path, unwritable data directory, or a malformed configuration produced after building the ignored-domains engine.
Common situations: Read-only or missing work/data directory, config file edited by hand with an invalid querylog section, or running AdGuard Home as a user without write permission to the data dir.
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
- creating new dns server config: %w
- constructing tls config: %w
- dnscrypt_config_file: %w
- reading cert file: %w
- starting dhcp server: %w
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/3e0019e7f0bda718.
Report an issue: GitHub.