deno: Deno.listen should throw on same port
const listener1 = Deno.listen({
port: 4505,
hostname: "0.0.0.0",
transport: "tcp",
});
console.log(listener1.addr);
const listener2 = Deno.listen({
port: 4505,
hostname: "0.0.0.0",
transport: "tcp",
});
console.log(listener2.addr);
Expected behavior
The code should throw according with docs.
Current behavior
The constant listener2 will have assigned a random port.

Also this test is hanging because of this https://github.com/denoland/deno_std/blob/main/http/server_test.ts#L1280
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (7 by maintainers)
That’s a nice discovery @sant123. The kernel version I tried was
5.17.5-300.fc36.x86_64. I discovered that there is a regression report for Linux kernel which can be found at: https://lore.kernel.org/netdev/CAFsF8vJ3wS-Yoy9tNZD2ZESevGenvYKqieD4F8+UztRsrJ=png@mail.gmail.com/T/ According to this, 6.0.16 to 6.0.18 suffers from this problem, so it’s most likely that you ran into this kernel regression.I’m going to close this issue since it’s turned out that this is actually not a issue with Deno. If you have another question or something, feel free to ask 😃
I gave it another try to run Fedora with vagrant (i.e. virtualbox) instead of docker, and got AddrInUse again. What you are seeing is really weird…