micro/go-micro · error

failed to join multicast group on all interfaces

Error message

failed to join multicast group on all interfaces

What it means

NewServer joins the mDNS multicast group on each interface for IPv4 and IPv6. If JoinGroup fails on every interface for both families, the server cannot receive multicast queries and returns this error. This mirrors the client-side check but occurs during server construction.

Source

Thrown at internal/util/mdns/server.go:132

		if err := p2.JoinGroup(config.Iface, &net.UDPAddr{IP: mdnsGroupIPv6}); err != nil {
			return nil, err
		}
	} else {
		ifaces, err := net.Interfaces()
		if err != nil {
			return nil, err
		}
		errCount1, errCount2 := 0, 0
		for _, iface := range ifaces {
			if err := p1.JoinGroup(&iface, &net.UDPAddr{IP: mdnsGroupIPv4}); err != nil {
				errCount1++
			}
			if err := p2.JoinGroup(&iface, &net.UDPAddr{IP: mdnsGroupIPv6}); err != nil {
				errCount2++
			}
		}
		if len(ifaces) == errCount1 && len(ifaces) == errCount2 {
			return nil, fmt.Errorf("failed to join multicast group on all interfaces")
		}
	}

	ipFunc := getOutboundIP
	if config.GetMachineIP != nil {
		ipFunc = config.GetMachineIP
	}

	s := &Server{
		config:     config,
		ipv4List:   ipv4List,
		ipv6List:   ipv6List,
		shutdownCh: make(chan struct{}),
		outboundIP: ipFunc(),
	}

	go s.recv(s.ipv4List)
	go s.recv(s.ipv6List)

View on GitHub (pinned to 24529f1404)

Solutions

  1. Enable multicast on at least one interface (ip link set dev eth0 multicast on)
  2. Verify a real interface with multicast support exists and is up
  3. Check that IPv6/IPv4 multicast is enabled in the host kernel and network
  4. Run the process with network privileges that permit joining multicast groups
Defensive patterns

Strategy: fallback

Validate before calling

var joined, total int
ifaces, _ := net.Interfaces()
for _, i := range ifaces {
    if i.Flags&net.FlagMulticast == 0 { continue }
    total++
    _ = joined // probe joinability via a test socket if needed
}
if total == 0 {
    log.Fatal("no multicast-capable interfaces; mDNS server cannot run")
}

Try / catch

srv, err := mdns.NewServer(&mdns.Config{Zone: zone})
if err != nil && strings.Contains(err.Error(), "failed to join multicast group on all interfaces") {
    return nil, fmt.Errorf("multicast join failed on all interfaces; enable multicast on a NIC: %w", err)
}

Prevention

When it happens

Trigger: NewServer (Register, TestServer_StartStop, TestServer_Lookup) when both error counters equal len(ifaces) after JoinGroup attempts on all interfaces.

Common situations: Interfaces without MULTICAST flag; containers/VMs whose virtual NICs don't support multicast; IPv6 multicast disabled in kernel; restricted sandbox privileges.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/a7b5e7cd02f45673. Report an issue: GitHub.