nodejs / nodejs/node

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

Ouverte
#65,400 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

http
Langage dominant
JavaScript
Étoiles
122k
Forks
37.3k
Merge moyen
4 j 2 h
PR mergées (30 j)
283

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par reproduire le problème avec le serveur HTTP fourni et les variantes de listen sous Linux sans prise en charge de TCPv4, puis suivez le chemin réseau de server.listen. Confirmez la correction en vérifiant qu’un serveur IPv6-only devient accessible et que le comportement existant de listen reste correct dans les tests réseau pertinents.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, node.js
Domaine
backend, networking
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.