# freeport-async

> Finds an available port for your application to use.

Latest version **2.0.0** (published 2019-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install freeport-async
pnpm add freeport-async
yarn add freeport-async
bun add freeport-async
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-10-11 |
| First published | 2015-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Expo |
| Maintainers | bbarthec, brentvatne, ccheever, charliecruzan, dsokal, esamelson, evanbacon, expoadmin, exponent, fson, ide, mczernek, quinlanj, sjchmiela, szymon20000, tcdavis, tsapeta, wkozyra |
| Keywords | port, free, open, new, fresh, clean, networking, mikeal |

## Links

- npm: https://www.npmjs.com/package/freeport-async
- Repository: https://github.com/expo/freeport-async
- Homepage: https://github.com/expo/freeport-async/blob/master/README.md
- Issues: https://github.com/expo/freeport-async/issues
- npm.io page: https://npm.io/package/freeport-async

## 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) — 2019-10-11
- 1.1.1 — 2017-01-12
- 1.1.0 — 2015-05-14
- 1.0.0 — 2015-05-12

## README

# freeport-async

Finds an available port for your application to use.
You can specify a range where to look for an available port.
And can also find a range of available ports for you to use.
You can also be used to test to see if a given port is available.

All functions are async and return Promises.

## Usage

### Basic

```js
let freeportAsync = require("freeport-async");

let portICanUse = await freeportAsync();
```

### Advanced

```js
let freeportAsync = require("freeport-async");

let portIn9000Range = await freeportAsync(9000);

let portAvailableForAnyOrLocalhost = await freeportAsync(9000, {
  hostnames: [null, "localhost"]
});

let isPort5000Available = await freeportAsync.availableAsync(5000);

let listOf5ConsecutiveAvailablePorts = await freeportAsync.rangeAsync(5);

let freeRangeIn12000Range = await freeportAsync.rangeAsync(3, 12000);
```

## Important Note

Note that this code just finds available ports, but doesn't reserve them in any way.
This means that if you have other code that might be looking for a port in the same range at the same time, you could run into issues.

Also, if you call `freeportAsync` twice in a row, it will often return the same port number twice. If you want to find two (or more) ports you can use, you need to call `freeportAsync.rangeAsync(<number-of-ports>, [startSearchFrom])`.

See also https://gist.github.com/mikeal/1840641

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