{"record":{"id":"0e6d7badc07e3def","repo":"tailscale/tailscale","slug":"magicsock-rebind-ipv4-failed-w","errorCode":null,"errorMessage":"magicsock: Rebind IPv4 failed: %w","messagePattern":"magicsock: Rebind IPv4 failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgengine/magicsock/magicsock.go","lineNumber":3799,"sourceCode":"\t}\n\treturn fmt.Errorf(\"failed to bind any ports (tried %v)\", ports)\n}\n\ntype currentPortFate uint8\n\nconst (\n\tkeepCurrentPort = currentPortFate(0)\n\tdropCurrentPort = currentPortFate(1)\n)\n\n// rebind closes and re-binds the UDP sockets.\n// We consider it successful if we manage to bind the IPv4 socket.\nfunc (c *Conn) rebind(curPortFate currentPortFate) error {\n\tif err := c.bindSocket(&c.pconn6, \"udp6\", curPortFate); err != nil {\n\t\tc.logf(\"magicsock: Rebind ignoring IPv6 bind failure: %v\", err)\n\t}\n\tif err := c.bindSocket(&c.pconn4, \"udp4\", curPortFate); err != nil {\n\t\treturn fmt.Errorf(\"magicsock: Rebind IPv4 failed: %w\", err)\n\t}\n\tif c.portMapper != nil {\n\t\tc.portMapper.SetLocalPort(c.LocalPort())\n\t}\n\tc.UpdatePMTUD()\n\treturn nil\n}\n\n// Rebind closes and re-binds the UDP sockets and resets the DERP connection.\n// It should be followed by a call to ReSTUN.\nfunc (c *Conn) Rebind() {\n\tmetricRebindCalls.Add(1)\n\tif err := c.rebind(keepCurrentPort); err != nil {\n\t\tc.logf(\"%v\", err)\n\t\treturn\n\t}\n\n\tvar ifIPs []netip.Prefix","sourceCodeStart":3781,"sourceCodeEnd":3817,"githubUrl":"https://github.com/tailscale/tailscale/blob/5201273aec737d6372ab7423c31c04ca3ca2a0c2/wgengine/magicsock/magicsock.go#L3781-L3817","documentation":"rebind: after tolerating an IPv6 bind failure, the required IPv4 socket bind also failed. magicsock considers IPv4 binding mandatory, so rebind returns this wrapped error; a later link-change event will attempt rebind again.","triggerScenarios":"Thrown at wgengine/magicsock/magicsock.go:3821 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for the bind failure cause (address in use, permission denied, or interface down).","Ensure the local IPv4 address is still assigned to an interface; a network change may have removed it.","Let magicsock retry after the network change settles; restart tailscaled if it does not recover."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5201273aec737d6372ab7423c31c04ca3ca2a0c2","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}