A Node.js utility to get an available TCP port with support for preferred ports, ranges, and port reservation.
get-port is a Node.js library that finds an available TCP port for applications, supporting preferred ports, ranges, and port reservation. It solves the problem of dynamically allocating ports without conflicts, which is crucial for local development, testing, and multi-service setups.
Node.js developers building servers, running parallel tests, or managing multiple local services that require dynamic port assignment.
Developers choose get-port for its dead-simple API, built-in race condition protection, and flexibility in port selection, making it the go-to solution for reliable port allocation in Node.js ecosystems.
Get an available TCP port
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Accepts single ports, arrays, or ranges via portNumbers(), allowing precise control over preferred ports, as shown in the usage examples.
Includes a locking mechanism and reserve option to prevent in-process conflicts, with detailed explanations in the 'Beware' section.
Can check ports on specific IPv4 or IPv6 addresses using the host option, useful for multi-homed systems.
Offers a straightforward API with clear examples, making integration easy for any Node.js project.
Only supports TCP ports, with no mention of UDP or other protocols, restricting use cases to TCP-based applications.
Ports are locked for only 15-30 seconds by default, which may be insufficient for long delays without using the reserve option, adding complexity.
Admits a tiny chance of race conditions with other processes, leading to potential EADDRINUSE errors that require manual handling.