# find-free-port

> find a free tcp port to listen locally

Latest version **2.0.0** (published 2018-06-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install find-free-port
pnpm add find-free-port
yarn add find-free-port
bun add find-free-port
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-06-25 |
| First published | 2014-11-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | mhzed |
| Maintainers | mhzed |
| Keywords | find, free, local, port, listen |

## Links

- npm: https://www.npmjs.com/package/find-free-port
- Repository: https://github.com/mhzed/find-free-port
- npm.io page: https://npm.io/package/find-free-port

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-06-25
- 1.2.0 — 2018-02-09
- 1.1.2 — 2018-02-09
- 1.1.1 — 2018-01-21
- 1.1.0 — 2017-12-17
- 1.0.2 — 2015-03-18
- 1.0.1 — 2014-11-28
- 1.0.0 — 2014-11-04

## README

find-free-port
--------

Find free tcp port or pors to listen on.  The definition of 'free' port is that connecting to this port and host ('localhost' by default) will not succeed, and thus 'free'.

## Installation
```bash
npm install find-free-port --save
```

## Examples

Find a free port to listen on that is >= 3000
```js
var fp = require("find-free-port")
fp(3000, function(err, freePort){
});
```
    
Find a free port to listen on that is >= 3000 and < 3100
```js
var fp = require("find-free-port")
fp(3000, 3100, function(err, freePort){
});
```
            
Find 3 free ports to listen on that is >= 3000 locally
```js
var fp = require("find-free-port")
fp(3000, 3100, '127.0.0.1', 3, function(err, p1, p2, p3){
});
```

Find a free port that is >= 3000 and at host 192.168.100.1
```js
var fp = require("find-free-port")
fp(3000, "192.168.100.1", function(err, freePort){
});
```

## Promise

If the callback is omitted, then the call returns a Promise that resolve to a list of avaiable ports:
```js
var fp = require("find-free-port")
fp(3000).then(([freep]) => {
    console.log('found ' + freep);
}).catch((err)=>{
    console.error(err);
});
```

---
_Source: https://npm.io/package/find-free-port · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
