free-port-finder
v1.0.1
Published
Scan and locate available TCP ports sequentially or randomly in Node.js.
Maintainers
Readme
free-port-finder
Why use free-port-finder? Development tools, tests, and Microservices need to bind to free network ports. Hardcoding port numbers leads to EADDRINUSE address conflict crashes.
A promise-based TCP port scanner that locates available network ports sequentially or randomly in Node.js.
⚡ Features
- Finds free TCP ports sequentially
- Guarantees address availability before resolving
- Lightweight, uses native node net module
📦 Installation
npm i free-port-finder🚀 Usage
import { findFreePort } from 'free-port-finder';
const port = await findFreePort(3000);
console.log('Available Port:', port); // 3000 (or next free port)⚙️ API Reference
findFreePort(startPort?)
startPort:number- Starting port scan (Default: 0 for random).
📺 Demonstration

📄 License
MIT License.
