AdguardTeam/AdGuardHome · error
hostname: %w
Error message
hostname: %w
What it means
addLease found that another lease already owns the requested hostname in hostsIndex, so it returns the hostname wrapped around errors.ErrDuplicated. The DHCP server enforces unique hostnames across leases so DNS/RDNS entries stay unambiguous.
Source
Thrown at internal/dhcpd/v4_unix.go:335
func (s *v4Server) addLease(l *dhcpsvc.Lease) (err error) {
r := s.conf.ipRange
leaseIP := net.IP(l.IP.AsSlice())
offset, inOffset := r.offset(leaseIP)
if l.IsStatic {
// TODO(a.garipov, d.seregin): Subnet can be nil when dhcp server is
// disabled.
if sn := s.conf.subnet; !sn.Contains(l.IP) {
return fmt.Errorf("subnet %s does not contain the ip %q", sn, l.IP)
}
} else if !inOffset {
return fmt.Errorf("lease %s (%s) out of range, not adding", l.IP, l.HWAddr)
}
// TODO(e.burkov): l must have a valid hostname here, investigate.
if l.Hostname != "" {
if _, ok := s.hostsIndex[l.Hostname]; ok {
return fmt.Errorf("hostname: %w", errors.ErrDuplicated)
}
s.hostsIndex[l.Hostname] = l
}
s.ipIndex[l.IP] = l
s.leases = append(s.leases, l)
s.leasedOffsets.set(offset, true)
return nil
}
// rmLease removes a lease with the same properties.
func (s *v4Server) rmLease(lease *dhcpsvc.Lease) (err error) {
if len(s.leases) == 0 {
return nil
}
View on GitHub (pinned to b41aefbe51)
Solutions
- Rename one of the conflicting clients' hostnames
- Remove or expire the stale lease holding the hostname (or reset leases)
- When resetting leases in bulk, deduplicate hostnames before insertion
Example fix
// before
{ hostname: "printer", mac: "aa:.." }
{ hostname: "printer", mac: "bb:.." }
// after
{ hostname: "printer", mac: "aa:.." }
{ hostname: "printer-2", mac: "bb:.." } Defensive patterns
Strategy: validation
Validate before calling
// dedupe hostnames before bulk add/reset
seen := map[string]bool{}
for _, l := range leases {
if l.Hostname != "" && seen[l.Hostname] { l.Hostname = "" }
seen[l.Hostname] = true
} Try / catch
if err := srv.addLease(l); errors.Is(err, errors.ErrDuplicated) {
// rename or clear the hostname and retry
} Prevention
- Deduplicate hostnames when merging lease sets
- Rename cloned devices to unique names
- Clear hostnames on conflicting imports rather than failing
When it happens
Trigger: Adding or resetting a lease whose Hostname already exists in s.hostsIndex under a different MAC/IP — e.g. two devices both claiming hostname "android-abc123", or re-adding a lease set containing a duplicate hostname.
Common situations: Cloned VMs/IoT devices with identical default hostnames; importing a lease file with duplicates; replacing a device while its old lease still holds the hostname.
Related errors
- no valid parts
- login: %w
- another client %q uses the same ClientID %q
- another client %q uses the same IP %q
- another client %q uses the same subnet %q
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/7617ca5220a71357.
Report an issue: GitHub.