nodejs / nodejs/node

Node.js server fails to bind on ipv6 if ipv4 is not available

Abierto
#65,400 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

http
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

Version

v24.18.1

Platform
Linux ssh2 6.18.43-alwaysdata #1 SMP PREEMPT_DYNAMIC Fri Aug  7 07:39:43 UTC 2026 x86_64 GNU/Linux
Subsystem

No response

What steps will reproduce the bug?
  1. Run a HTTP server (code below)
  2. Try to connect to it (via e.g. python, netcat, a browser etc.)

code:

const http = require("http");
const server = http.createServer((req,res)=>{
     res.writeHead(200, "Content-Type", "text/plain");
     res.write("ok");
     res.end();
});

server.listen({ port: 8300 }, ()=> {
    console.log("Server is running");
});

I also tried all the following:

server.listen({ port: 8300, host: "::" }, ()=> {
    console.log("Server is running");
});

server.listen({ port: 8300, host: "::", ipv6Only: true }, ()=> {
    console.log("Server is running");
});

server.listen({ port: 8300, host: "", ipv6Only: true }, ()=> {
    console.log("Server is running");
});

server.listen({ port: 8300, host: "0.0.0.0", ipv6Only: true }, ()=> {
    console.log("Server is running");
});

server.listen({ port: 8300, host: "::1", ipv6Only: true }, ()=> {
    console.log("Server is running");
});

server.listen({ port: 8300, host: "" }, ()=> {
    console.log("Server is running");
});

server.listen(8300, "::", ()=> {
    console.log("Server is running");
});

server.listen(8300, "", ()=> {
    console.log("Server is running");
});

// maybe even more i forgot
How often does it reproduce? Is there a required condition?

TCPv4 must not be available on the OS.
For example, netstat -lntp must say this:

netstat: no support for `AF INET (tcp)' on this system.

netstat -lntp6 must not say that, however - instead, it should succeed:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
What is the expected behavior? Why is that the expected behavior?

The server should be accessible

What do you see instead?

No error is thrown or logged, however, I cannot connect to the server in any imaginable way

Additional information

edit: offensive comment removed by moderator

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el problema con el servidor HTTP proporcionado y las variantes de listen en Linux sin compatibilidad con TCPv4; después, sigue la ruta de red de server.listen. Confirma la corrección verificando que un servidor IPv6-only sea accesible y que el comportamiento existente de listen siga siendo correcto en las pruebas de red relevantes.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
backend, networking
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.