AdguardTeam/AdGuardHome · error

creating dhcpv4 srv: %w

Error message

creating dhcpv4 srv: %w

What it means

Creating the DHCPv4 server (v4Create) failed and the v4 config was considered enabled (valid RangeStart), so setServers propagates the error and Create aborts. Typical wrapped causes are invalid ranges, gateway, or interface binding failures inside v4Create/Validate.

Source

Thrown at internal/dhcpd/dhcpd.go:176

}

// 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()

	s.srv4, err = v4Create(&v4conf)
	if err != nil {
		if v4conf.Enabled {
			return false, false, fmt.Errorf("creating dhcpv4 srv: %w", err)
		}

		s.conf.Logger.DebugContext(ctx, "creating dhcpv4 server", slogutil.KeyError, err)
	}

	v6conf := conf.Conf6
	v6conf.Logger = s.conf.Logger.With("ip_version", "6")
	v6conf.InterfaceName = s.conf.InterfaceName
	v6conf.notify = s.onNotify
	v6conf.Enabled = s.conf.Enabled && len(v6conf.RangeStart) != 0

	s.srv6, err = v6Create(v6conf)
	if err != nil {
		return v4conf.Enabled, false, fmt.Errorf("creating dhcpv6 srv: %w", err)
	}

	return v4conf.Enabled, v6conf.Enabled, nil
}

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Inspect the wrapped error for the concrete validation failure (range/gateway/subnet)
  2. Correct the DHCPv4 settings per the underlying message
  3. Verify the network interface name exists and is up
Defensive patterns

Strategy: validation

Validate before calling

// run config validation before Create
if err := conf.Conf4.Validate(); err != nil { return err } // surfaces range/gateway issues early

Try / catch

if _, err := dhcpd.Create(ctx, conf); err != nil && strings.Contains(err.Error(), "creating dhcpv4") { /* show wrapped validation detail to user */ }

Prevention

When it happens

Trigger: Calling Create with DHCPv4 enabled and RangeStart set but another setting invalid (range end outside subnet, gateway inside range, bad interface) — the Validate errors 103–106 surface through this wrapper.

Common situations: Applying a new DHCP config via the UI/API with an inconsistent range/gateway/subnet combination; interface renamed or missing.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/4323da35fef5cf5a. Report an issue: GitHub.