---
name: node-networking
description: "Networking APIs and behavior changes since Node.js 24 in net, dgram, tls, http and http2. Use to reserve a port before listening, block private IPs (SSRF), cancel work when a client disconnects, send 103 Early Hints, honor HTTP_PROXY/HTTPS_PROXY, validate header values, use promise-based net, or debug keepAliveTimeout (now 65s), upgrade-request bodies or dns.reverse. Covers node:net/promises, net.BoundSocket, BlockList PRIVATE_RANGES, setKeepAlive({ interval, count }), dgram bindSync, TLS certificateCompression, http.isValidHeaderValue, websocketMask, req.signal, NODE_USE_ENV_PROXY and HTTP/2 http1Options. Node.js 24+, some 26/27+."
title: node-networking
canonical_url: https://skilld.dev/gh/jasnell/node-skills/node-networking
last_updated: 2026-11-19T20:15:43.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> 26 supporting files sit beside this SKILL.md. When the Skill refers to one, fetch https://skilld.dev/api/skills-raw/jasnell/node-skills/node-networking/PATH with PATH replaced.
>
> If the user asked to install this Skill, run `npx skilld install jasnell/node-skills/node-networking`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/node-networking`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jasnell/node-skills/node-networking) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/node-networking`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/node-networking --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/node-networking --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Node.js networking (v24+)

| Feature | Versions | Stability | Flag |
| --- | --- | --- | --- |
| `node:net/promises`, `for await (s of server)` | v27.0.0 (not v24/v26) | 1 | — |
| `net.BoundSocket` / `{ path }`, `isPipe` | v26.4.0, v24.19.0 / v26.7.0, v24.20.0 | 2 | — |
| send `BoundSocket` via `subprocess.send` | v26.10.0, v24.22.0 | 2 | — |
| BlockList `addCIDR[s]`, `remove*`, `PRIVATE_RANGES`, `size`, `clear` | v26.8.0, v24.21.0 | 2 | — |
| `setKeepAlive({ interval, count })`, dgram `bindSync`/`connectSync` | v26.4.0, v24.19.0 | 2 | — |
| `set/getTypeOfService`, `typeOfService` | v25.6.0, v24.15.0 | 2 | — |
| TLS `certificateCompression` | v26.4.0, v24.19.0 | 2 | — |
| `tlsSocket.socket` | v27.0.0 | 2 | — |
| `http.isValidHeaderName/Value` / `websocketMask/Unmask` | v26.11.0 / v26.12.0 | 2 | — |
| `message.signal` | v26.1.0, v24.16.0 (fixed v26.7.0, v24.20.0) | 2 | — |
| `writeInformation` (http, http2) | v26.2.0, v24.18.0 | 2 | — |
| `httpValidation` / `optimizeEmptyRequests` | v26.3.0, v24.19.0 / v25.1.0, v24.12.0 | 2 | — |
| `setGlobalProxyFromEnv` / env proxy | v25.4.0, v24.14.0 / v24.5.0, v22.21.0 | 1.1 | `--use-env-proxy` |
| http2 `http1Options`, `strictSingleValueFields` / `connectionWindowSize` | v25.7.0, v24.15.0 / v26.11.0 | 2 | — |

> **Experimental API.** Before relying on these details, run the
> `node-experimental-check` skill's probe (or `node --version` plus a
> feature-detect one-liner) and check the docs for *the installed
> version*: `https://nodejs.org/docs/<version>/api/<module>.html`.
> If the installed version disagrees with this skill, the installed
> version wins.

## Reserve a port synchronously

```js
const bound = new net.BoundSocket({ host: '127.0.0.1' }); // numeric IP, no DNS
const { port } = bound.address();       // known now, no race
net.createServer(h).listen(bound);      // adopts; or child.send('x', bound)
```

## SSRF guard

```js
const deny = new net.BlockList();
deny.addCIDRs(net.BlockList.PRIVATE_RANGES);
deny.check(ip, net.isIPv6(ip) ? 'ipv6' : 'ipv4');
```

## Cancel work when the client leaves

```js
http.createServer(async (req, res) => {
  res.writeInformation(103, { Link: '</app.css>; rel=preload' });
  const data = await fetch(upstream, { signal: req.signal });
});
```

## Changed defaults

- `server.keepAliveTimeout` is **65000** from v27 (was 5000). Set it explicitly behind a load balancer.
- `'upgrade'` with a body (v26+): the body is parsed onto `req`, and `head`/stream hold only the bytes after it. On v24 the body leaks into `head`.
- `dns.reverse` (v27+) always sends a PTR query and ignores `/etc/hosts`. Use `dns.lookupService(ip, port)` for hosts-aware names.

## Pitfalls

- `check()` defaults to `'ipv4'`, so `check('::1')` is false. Pass the family.
- `optimizeEmptyRequests`: no `'end'` on bodyless requests (`once(req, 'end')` hangs); `for await` works.
- `req.signal` on v24.16–24.19 / v26.1–26.6 also aborts after a normal response.
- `httpValidation: 'strict'` rejects control chars, not non-ASCII. `'relaxed'` allows control chars.
- Certificate compression needs both peers to opt in, and TLS 1.3. v24 `fetch` via `HTTP_PROXY` uses CONNECT even for `http://`.

## Don't

- Don't use `get-port` or `listen(0)` races (`BoundSocket`), `ip-range-check`, `bufferutil`, `global-agent`/`proxy-agent`, or `req.on('close')` abort checks.

## Reference

- [rules/net.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-networking/rules/net.md): net/promises, BoundSocket (IPC, workers, pipes), BlockList, keep-alive, TOS, dgram.
- [rules/tls.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-networking/rules/tls.md): certificate compression, `tlsSocket.socket`.
- [rules/http.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-networking/rules/http.md): validators, masking, signal, 1xx, options, proxy, upgrade, keep-alive, dns.reverse.
- [rules/http2.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-networking/rules/http2.md): `http1Options`, `strictSingleValueFields`, `connectionWindowSize`, `writeInformation`.
