{"record":{"id":"70640cf4bd45038e","repo":"micro/go-micro","slug":"failed-to-bind-to-any-multicast-udp-port","errorCode":null,"errorMessage":"failed to bind to any multicast udp port","messagePattern":"failed to bind to any multicast udp port","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/mdns/client.go","lineNumber":208,"sourceCode":"\t\treturn nil, fmt.Errorf(\"failed to bind to any unicast udp port\")\n\t}\n\n\tif uconn4 == nil {\n\t\tuconn4 = &net.UDPConn{}\n\t}\n\n\tif uconn6 == nil {\n\t\tuconn6 = &net.UDPConn{}\n\t}\n\n\tmconn4, err4 := net.ListenUDP(\"udp4\", mdnsWildcardAddrIPv4)\n\tmconn6, err6 := net.ListenUDP(\"udp6\", mdnsWildcardAddrIPv6)\n\tif err4 != nil && err6 != nil {\n\t\tlogger.Logf(logger.ErrorLevel, \"[mdns] failed to bind to udp port: %v %v\", err4, err6)\n\t}\n\n\tif mconn4 == nil && mconn6 == nil {\n\t\treturn nil, fmt.Errorf(\"failed to bind to any multicast udp port\")\n\t}\n\n\tif mconn4 == nil {\n\t\tmconn4 = &net.UDPConn{}\n\t}\n\n\tif mconn6 == nil {\n\t\tmconn6 = &net.UDPConn{}\n\t}\n\n\tp1 := ipv4.NewPacketConn(mconn4)\n\tp2 := ipv6.NewPacketConn(mconn6)\n\t_ = p1.SetMulticastLoopback(true)\n\t_ = p2.SetMulticastLoopback(true)\n\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/internal/util/mdns/client.go#L190-L226","documentation":"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.","triggerScenarios":"newClient (via Query or Listen) when net.ListenUDP fails for both udp4 and udp6 on mdnsWildcardAddr (port 5353).","commonSituations":"Another process already holds :5353 exclusively; restrictive container/network sandbox blocking multicast; missing SO_REUSEADDR/SO_REUSEPORT support; no multicast-capable interfaces.","solutions":["Find and stop any other process bound to port 5353 (lsof -i :5353)","Run in an environment that allows multicast UDP and SO_REUSEPORT","Check that multicast-capable interfaces exist and are up","Review the logged bind errors for the OS-level cause (EADDRINUSE, EPERM, etc.)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"probe, err := net.ListenUDP(\"udp4\", &net.UDPAddr{IP: net.IPv4zero, Port: 5353})\nif err != nil {\n    log.Printf(\"multicast port 5353 unavailable: %v\", err)\n}\nelse { probe.Close() }","typeGuard":null,"tryCatchPattern":"c, err := newClient(config)\nif err != nil && strings.Contains(err.Error(), \"failed to bind to any multicast udp port\") {\n    log.Warn(\"mDNS multicast bind failed; check port 5353 and sandbox permissions\")\n    return nil, err\n}","preventionTips":["Don't bind :5353 exclusively in other app code; always use SO_REUSEADDR/REUSEPORT","Stop conflicting mDNS daemons (Avahi/Bonjour) in the same network namespace","Confirm containers allow multicast UDP"],"tags":["network","udp","mdns","multicast"],"backgroundTag":"udp-bind-failure","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}