node:net API Reference

Address helpers and Elide 1.5.0 TCP socket limitations

Address helpers and value classes are available:

import net from "node:net";

console.log(net.isIP("127.0.0.1")); // 4
console.log(net.isIP("::1")); // 6
console.log(net.isIP("not-an-ip")); // 0

const blocked = new net.BlockList();
blocked.addAddress("127.0.0.1");
console.log(blocked.check("127.0.0.1")); // true

The module exports Socket, Stream, Server, BlockList, SocketAddress, connect, createConnection, createServer, the IP helpers, and the default auto-select-family settings.

Elide 1.5.0 socket limitation

TCP servers can bind and report an address, but listening, connection, data, and close callbacks do not run in a basic one-shot script before the process exits. Elide 1.5.0 therefore should not be used as a general node:net server or client despite exposing the compatibility surface.

The separate node:tls module is present, but it inherits the same lifecycle risk for live sockets. Unix-domain sockets and network-facing examples require the same caution.

When sandbox flags are active, network access is controlled by --allow-net[=HOSTS] and --deny-net <HOSTS>.