{"record":{"id":"e5db1047a569d592","repo":"AlexxIT/go2rtc","slug":"no-interfaces-for-listen","errorCode":null,"errorMessage":"no interfaces for listen","messagePattern":"no interfaces for listen","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/mdns/client.go","lineNumber":202,"sourceCode":"\t\t\t\t// 1. Allow multicast UDP to listen concurrently across multiple listeners\n\t\t\t\t_ = SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)\n\t\t\t})\n\t\t},\n\t}\n\n\tctx := context.Background()\n\n\tfor _, ipn := range nets {\n\t\tconn, err := lc1.ListenPacket(ctx, \"udp4\", ipn.IP.String()+\":5353\") // same port important\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tb.Nets = append(b.Nets, ipn)\n\t\tb.Sends = append(b.Sends, conn)\n\t}\n\n\tif b.Sends == nil {\n\t\treturn errors.New(\"no interfaces for listen\")\n\t}\n\n\t// 3. Create receiver\n\tlc2 := net.ListenConfig{\n\t\tControl: func(network, address string, c syscall.RawConn) error {\n\t\t\treturn c.Control(func(fd uintptr) {\n\t\t\t\t// 1. Allow multicast UDP to listen concurrently across multiple listeners\n\t\t\t\t_ = SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)\n\n\t\t\t\t// 2. Disable loop responses\n\t\t\t\t_ = SetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, 0)\n\n\t\t\t\t// 3. Allow receive multicast responses on all this addresses\n\t\t\t\tmreq := &syscall.IPMreq{\n\t\t\t\t\tMultiaddr: [4]byte{224, 0, 0, 251},\n\t\t\t\t}\n\t\t\t\t_ = SetsockoptIPMreq(fd, syscall.IPPROTO_IP, syscall.IP_ADD_MEMBERSHIP, mreq)\n","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/mdns/client.go#L184-L220","documentation":"The mDNS client's ListenMulticastUDP walks all host interfaces, creates a UDP socket per eligible interface, and joins the multicast group on each. If none of the interfaces yielded a usable socket (b.Sends stayed nil), there is nothing to multicast on and the function returns this error before creating the receiver.","triggerScenarios":"Calling mdns Discovery/Serve on a host with no non-loopback interfaces matching the multicast rules — e.g. no network up, all interfaces down, or interfaces whose addresses are filtered out (loopback-only, link-local filtered by code, or IPv6-only where the code expects IPv4).","commonSituations":"Running go2rtc inside a Docker container launched with `--network none` or no published networks; running in a sandbox/CI without network interfaces; all interfaces administratively down; Windows/macOS VPN adapters filtered out; calling Discovery before the network is up at boot.","solutions":["Ensure at least one network interface is up with a valid IPv4 address before starting mDNS discovery (check `ip addr` / `ifconfig`).","If running in Docker, attach the container to a real network (`--network bridge` or `host`) instead of `none` so multicast-capable interfaces exist.","Exclude loopback-only setups: give the host/container an address on the LAN, since loopback does not carry multicast joins the way the code expects.","Retry discovery after network-manager has brought interfaces up (common on freshly booted systems)."],"exampleFix":"// before: start discovery immediately at boot before interfaces are up\nserver.OnConnect(func() { go mdns.Discovery(...) }) // no interfaces for listen\n\n// after: wait for a non-loopback IPv4 interface\nwaitForNetworkInterface() // poll net.Interfaces() for up, non-loopback IPv4\ngo mdns.Discovery(...)","handlingStrategy":"validation","validationCode":"func hasMulticastCapableInterface() bool {\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn false\n\t}\n\tfor _, ifc := range ifaces {\n\t\tif ifc.Flags&net.FlagUp == 0 || ifc.Flags&net.FlagLoopback != 0 {\n\t\t\tcontinue\n\t\t}\n\t\taddrs, _ := ifc.Addrs()\n\t\tfor _, a := range addrs {\n\t\t\tif ipn, ok := a.(*net.IPNet); ok && ipn.IP.To4() != nil {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":"if !hasMulticastCapableInterface() {\n\tlog.Warn(\"mdns: no usable multicast interface, skipping discovery\")\n\treturn\n}\nif err := mdnsDiscovery(...); err != nil && strings.Contains(err.Error(), \"no interfaces for listen\") {\n\t// retry after delay once network is up\n}","preventionTips":["Wait for a non-loopback IPv4 interface to be up before starting discovery (poll net.Interfaces)","In Docker, use --network bridge/host; --network none guarantees this error","On boot systems, hook discovery start to network-online rather than process start"],"tags":["mdns","network","multicast","discovery","interfaces"],"backgroundTag":"no-network-interface","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}