server.listen()
The method that starts a Node.js server accepting connections on a port; it emits listening once it is ready.
In more detail
server.address().port then tells you which port was actually chosen, which matters when you asked for port 0. The callback or listening event is the signal that the server can accept requests.
Related terms
- ephemeral port — A temporary port number picked automatically by the operating system from a reserved range.
- node:http — The built-in Node.js module for writing HTTP/1.1 servers and clients, which web frameworks such as Express and Fastify build on.
Taught in
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services
- Routing & Middleware: Path Parsing & Async Context — Node.js Internals & Backend Services
- Native HTTP/2 Protocols: Multiplexed Streams & Push — Node.js Internals & Backend Services
- Native WebSockets: Bidirectional Real-Time Streams — Node.js Internals & Backend Services
- Cluster Architecture: node:cluster & Zero-Downtime — Node.js Internals & Backend Services
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services