micro/go-micro · error

failed to bind to any multicast udp port

Error message

failed to bind to any multicast udp port

What it means

newClient attempts to bind multicast wildcard UDP sockets (port 5353) for IPv4 and IPv6. If both multicast binds fail, the client cannot participate in mDNS multicast and returns this error. The underlying OS errors are logged just before.

Source

Thrown at internal/util/mdns/client.go:208

		return nil, fmt.Errorf("failed to bind to any unicast udp port")
	}

	if uconn4 == nil {
		uconn4 = &net.UDPConn{}
	}

	if uconn6 == nil {
		uconn6 = &net.UDPConn{}
	}

	mconn4, err4 := net.ListenUDP("udp4", mdnsWildcardAddrIPv4)
	mconn6, err6 := net.ListenUDP("udp6", mdnsWildcardAddrIPv6)
	if err4 != nil && err6 != nil {
		logger.Logf(logger.ErrorLevel, "[mdns] failed to bind to udp port: %v %v", err4, err6)
	}

	if mconn4 == nil && mconn6 == nil {
		return nil, fmt.Errorf("failed to bind to any multicast udp port")
	}

	if mconn4 == nil {
		mconn4 = &net.UDPConn{}
	}

	if mconn6 == nil {
		mconn6 = &net.UDPConn{}
	}

	p1 := ipv4.NewPacketConn(mconn4)
	p2 := ipv6.NewPacketConn(mconn6)
	_ = p1.SetMulticastLoopback(true)
	_ = p2.SetMulticastLoopback(true)

	ifaces, err := net.Interfaces()
	if err != nil {
		return nil, err

View on GitHub (pinned to 24529f1404)

Solutions

  1. Find and stop any other process bound to port 5353 (lsof -i :5353)
  2. Run in an environment that allows multicast UDP and SO_REUSEPORT
  3. Check that multicast-capable interfaces exist and are up
  4. Review the logged bind errors for the OS-level cause (EADDRINUSE, EPERM, etc.)
Defensive patterns

Strategy: try-catch

Validate before calling

probe, err := net.ListenUDP("udp4", &net.UDPAddr{IP: net.IPv4zero, Port: 5353})
if err != nil {
    log.Printf("multicast port 5353 unavailable: %v", err)
}
else { probe.Close() }

Try / catch

c, err := newClient(config)
if err != nil && strings.Contains(err.Error(), "failed to bind to any multicast udp port") {
    log.Warn("mDNS multicast bind failed; check port 5353 and sandbox permissions")
    return nil, err
}

Prevention

When it happens

Trigger: newClient (via Query or Listen) when net.ListenUDP fails for both udp4 and udp6 on mdnsWildcardAddr (port 5353).

Common situations: Another process already holds :5353 exclusively; restrictive container/network sandbox blocking multicast; missing SO_REUSEADDR/SO_REUSEPORT support; no multicast-capable interfaces.

Related errors


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