{"record":{"id":"3e1dd46d5e8e98b5","repo":"slackhq/nebula","slug":"error-windows-bind-w","errorCode":null,"errorMessage":"error windows.Bind(): %w","messagePattern":"error windows\\.Bind\\(\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"udp/udp_rio_windows.go","lineNumber":137,"sourceCode":"\n\terr = u.rx.Open()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error rx.Open(): %w\", err)\n\t}\n\n\terr = u.tx.Open()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error tx.Open(): %w\", err)\n\t}\n\n\tu.rq, err = winrio.CreateRequestQueue(u.sock, packetsPerRing, 1, packetsPerRing, 1, u.rx.cq, u.tx.cq, 0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error CreateRequestQueue: %w\", err)\n\t}\n\n\terr = windows.Bind(u.sock, sa)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error windows.Bind(): %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (u *RIOConn) ListenOut(r EncReader, flush func()) error {\n\tbuffer := make([]byte, MTU)\n\n\tvar lastRecvErr time.Time\n\n\tfor {\n\t\t// Just read one packet at a time\n\t\tn, rua, err := u.receive(buffer)\n\n\t\tif err != nil {\n\t\t\tif errors.Is(err, net.ErrClosed) {\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/udp/udp_rio_windows.go#L119-L155","documentation":"This error wraps windows.Bind failing when binding the RIO socket to the requested address after the RIO request queue was created successfully. Bind errors carry the underlying winsock error (e.g. WSAEADDRINUSE, WSAEACCES) via %w, and bind() returns it to NewRIOListener.","triggerScenarios":"NewRIOListener -> bind(): windows.Bind(u.sock, sa) fails because the requested address:port is already in use by another socket, is reserved, or the address does not exist on the host.","commonSituations":"Another instance of the app (or another service) already holds the UDP port; port falls in Windows' excluded port ranges (netsh int ipv4 show excludedportrange protocol=udp, often carved out by Hyper-V); binding to an IP that is no longer assigned to the machine; insufficient privileges.","solutions":["Check the wrapped error: WSAEADDRINUSE means the port is taken - find/stop the other process or pick a different port.","Verify the listen address exists on the host (correct interface IP, not a stale address).","Check Windows excluded port ranges and move the port out of them.","Ensure ExclusiveAddrUse/privilege requirements are met if WSAEACCES is returned."],"exampleFix":"// before\nerr = windows.Bind(u.sock, sa)\nif err != nil {\n\treturn fmt.Errorf(\"error windows.Bind(): %w\", err)\n}\n// after\nerr = windows.Bind(u.sock, sa)\nif err != nil {\n\treturn fmt.Errorf(\"error windows.Bind(): %w\", err) // caller should check errors.Is(err, windows.WSAEADDRINUSE) and retry on a new port\n}","handlingStrategy":"retry","validationCode":"conn, err := net.ListenPacket(\"udp\", addr) // probe availability first\nif err != nil {\n\treturn fmt.Errorf(\"udp port %s unavailable: %w\", addr, err)\n}\nconn.Close()","typeGuard":"func isAddrInUse(err error) bool { return errors.Is(err, windows.WSAEADDRINUSE) || errors.Is(err, syscall.WSAEADDRINUSE) }","tryCatchPattern":"conn, err := udp.NewListener(logger, settings)\nif err != nil && isAddrInUse(err) {\n\t// pick a new port or wait for the current holder to release, then retry\n}","preventionTips":["Check netsh excluded port ranges before choosing fixed UDP ports on Windows.","Use a port-allocation/probing step before startup.","Ensure only one instance of the service uses the port (singletons/locks).","Bind to a verified local interface IP, not a stale address."],"tags":["windows","udp","bind","network"],"backgroundTag":"address-already-in-use","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}