AdguardTeam/AdGuardHome · critical
loading db: %w
Error message
loading db: %w
What it means
The DHCP server failed during initial database loading (dbLoad) at Create time; the message wraps any of the read/decode/lease-conversion/reset errors (errors 109–112). It prevents the server from starting with an unusable lease DB.
Source
Thrown at internal/dhcpd/dhcpd.go:154
s.conf.Conf4 = conf.Conf4
s.conf.Conf6 = conf.Conf6
if s.conf.Enabled && !v4Enabled && !v6Enabled {
return nil, fmt.Errorf("neither dhcpv4 nor dhcpv6 srv is configured")
}
// Migrate leases db if needed.
err = migrateDB(conf)
if err != nil {
// Don't wrap the error since it's informative enough as is.
return nil, err
}
// Don't delay database loading until the DHCP server is started,
// because we need static leases functionality available beforehand.
err = s.dbLoad()
if err != nil {
return nil, fmt.Errorf("loading db: %w", err)
}
return s, nil
}
// setServers updates DHCPv4 and DHCPv6 servers created from the provided
// configuration conf. It returns the status of both the DHCPv4 and the DHCPv6
// servers, which is always false for corresponding server on any error.
func (s *server) setServers(
ctx context.Context,
conf *ServerConfig,
) (v4Enabled, v6Enabled bool, err error) {
v4conf := conf.Conf4
v4conf.Logger = s.conf.Logger.With("ip_version", "4")
v4conf.InterfaceName = s.conf.InterfaceName
v4conf.notify = s.onNotify
v4conf.Enabled = s.conf.Enabled && v4conf.RangeStart.IsValid()
View on GitHub (pinned to b41aefbe51)
Solutions
- Read the wrapped error to identify the specific stage (read/decode/parse/reset)
- Fix or delete the offending leases file (dynamic leases are re-acquired automatically)
- Ensure the service user has read/write access to the data directory
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check DB readability/validity
if data, err := os.ReadFile(dbPath); err == nil && !json.Valid(data) { /* move aside */ } Try / catch
s, err := dhcpd.Create(ctx, conf)
if err != nil {
if strings.Contains(err.Error(), "loading db") { /* recover/rotate leases file, retry once */ }
return err
} Prevention
- Keep the data dir writable and backed up
- Treat wrapped 'loading db' errors as recoverable by resetting leases
When it happens
Trigger: Calling Create when the leases file is unreadable, invalid JSON, contains bad MAC/RFC3339 values, or lease data incompatible with current config.
Common situations: First start after a crash corrupted leases.json; permission problems in the data dir; subnet/range changes invalidating stored leases.
Related errors
- parsing hardware address: %w
- parsing expiry time: %w
- decoding db: %w
- reading db: %w
- resetting dhcpv4 leases: %w
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/92d50623f8623ed3.
Report an issue: GitHub.