-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: EADDRINUSE when binding both IPv4 and IPv6 all addresses on Linux #7200
Comments
That's because libuv uses dual-stack mode by default, i.e., the IPv6 socket listens on Libuv supports IPv6-only mode but node doesn't expose it. If you apply the patch below, your example should work: diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc
index 6904b27..1618493 100644
--- a/src/tcp_wrap.cc
+++ b/src/tcp_wrap.cc
@@ -239,7 +239,7 @@ void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
if (err == 0) {
err = uv_tcp_bind(&wrap->handle_,
reinterpret_cast<const sockaddr*>(&addr),
- 0);
+ UV_TCP_IPV6ONLY);
}
args.GetReturnValue().Set(err);
} |
Thanks! So would you say that the output of |
So to clarify the current behaviour:
This dual-stack behaviour looks to only apply to Linux. On OS X and Windows, I can bind Would it be feasible to disable dual-stack mode if an explicit IPv6 style address is given to |
Yes, the patch I posted would do that, but it might be contrary to what Linux users would expect. |
I'm fine with |
You can also change this default behaviour with
By default, this is 0, which means it binds to both IPv4 and IPv6. If http://serverfault.com/questions/408667/how-do-i-disable-ipv4-mapped-ipv6 Anyway, this is not an issue with NodeJS. This is the defaults of your |
Moving to #9390 |
On a IPv6 enabled Linux machine, I observe certain daemons being able to bind on all v4 and v6 interfaces on a single pid, like
sshd
(output ofss -tnlp
):Trying to replicate the same in node, the second
.listen
always seems to fail:Observed on Linux 3.16.0 and 4.4.12. It works on OS X, by the way.
The text was updated successfully, but these errors were encountered: