server-ready is a lightweight Node.js utility designed to ascertain when a network server is listening and ready to accept TCP connections on a specified port. The package operates by repeatedly attempting to establish a TCP connection to the target port, polling every 250 milliseconds until a connection is successful or a default timeout of 20 seconds is reached. While functional, it is important to note that the package, currently at version 0.3.1, has not received updates since 2017, suggesting it is unmaintained. It is primarily intended for use in Node.js scripts, deployment processes, or testing environments where programmatic waiting for server startup is required. Its key differentiator is its simplicity and singular focus on port availability, without deeper application-level health checks.
npm install server-readyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `server-ready` to wait for a simulated HTTP server to become available on a specific port, then makes a request to confirm.
Evaluate alternatives like `wait-port`, `tcp-port-used`, or implement custom polling logic for critical applications. If `server-ready` is indispensable, consider forking and maintaining it or thoroughly auditing its codebase.
Explicitly set `serverReady.timeout` to an appropriate value (in milliseconds) before calling the function, or pass the timeout as an argument: `serverReady(port, host, timeoutMs, cb)`.
For robust readiness checks, combine `server-ready` with an application-specific health check (e.g., making an HTTP GET request to a `/health` endpoint and checking the response status) once the port is reported as open.
Verify the server process is correctly starting and listening on the specified port. Increase the `serverReady.timeout` if the server takes longer to initialize. Check firewall rules that might be preventing `server-ready` from connecting.
Ensure your project or file uses CommonJS (`.js` files without `"type": "module"` in `package.json`, or `.cjs` files) when requiring `server-ready`. If you must use ES modules, consider a wrapper or use a tool like `createRequire` from Node.js's `module`.
Ensure no other application is running on the target port. Use a different port for your server, or gracefully shut down the conflicting process before starting your server and using `server-ready`.
No dependency data recorded yet.