Repository navigation
http2: code examples does not work on Windows with port 80 #14304
Copy link
Copy link
Closed
Labels
docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.
Description
Activity
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.
on Jul 16, 2017 Will look into it! Thank you! :-)
Reacted by Vse Mozhe Butyping @vsemozhetbyt — is this still the case for you?
@apapirovski Yes, the behavior from the first post remains with Node.js 8.7.0 or the last nightly build.
Reacted by Anatoli Papirovski@vsemozhetbyt Could you try the same with
httpornetwhen you have a moment?Reacted by Vse Mozhe Buty@apapirovski Let me know if I use wrong test examples.
Server:'use strict'; const http = require('http'); const hostname = 'localhost'; const port = 81; const server = http.createServer((req, res) => { console.log(req.headers); res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); });
Client:
'use strict'; const http = require('http'); http.get({ hostname: 'localhost', port: 81, path: '/', }, (res) => { console.log(res.headers); });
Port 81, Server:
Server running at http://localhost:81/ { host: 'localhost:81', connection: 'close' }
Port 81, Client:
{ 'content-type': 'text/plain', date: 'Thu, 19 Oct 2017 12:30:28 GMT', connection: 'close', 'content-length': '12' }
Port 80, Server:
Server running at http://localhost:80/ { host: 'localhost', connection: 'close' }
Port 80, Client:
{ 'content-type': 'text/plain', date: 'Thu, 19 Oct 2017 12:31:35 GMT', connection: 'close', 'content-length': '12' }
Thanks so much for testing
httptoo! I think I have a rough lead on what's going on. Will update later tonight when I have a moment to confirm whether I'm right or not.Reacted by Vse Mozhe Buty- added a commit that references this issue
on Oct 23, 2017 - added a commit that references this issue
on Oct 26, 2017 - added a commit that references this issue
on Dec 7, 2017 - added a commit that references this issue
on Jul 27, 2026
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.http2Issues and PRs related to the http2 subsystem.Issues and PRs related to the http2 subsystem.
Refs: #14239 (http2.md)
The first examples from "Core API" chapter do not work properly on Windows with port 80 but work with other ports.
I've added some output and repeated request for easier debugging. Here are the code and output with port 81:
Server:
Client:
Server output:
Client output:
When I change the port in both examples into 80, I get:
Server output:
(node:4792) ExperimentalWarning: The http2 module is an experimental API.Client output:
FWIW, I've tried to see what was going on with TCPView:

The first two is the Server, the last two are Client requests and they are trying to connect the 443 port.