# get-ports

> gets multiple open ports

Latest version **1.0.3** (published 2016-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-ports
pnpm add get-ports
yarn add get-ports
bun add get-ports
```

## 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 | 1.0.3 |
| Published | 2016-03-15 |
| First published | 2015-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | get, port, find, portfind, finding, finds, gets, portfinding, portfinder, multiple |

## Links

- npm: https://www.npmjs.com/package/get-ports
- Repository: https://github.com/Jam3/get-ports
- Issues: https://github.com/Jam3/get-ports/issues
- npm.io page: https://npm.io/package/get-ports

## Dependencies (1)

- [map-limit](https://npm.io/package/map-limit.md) 0.0.1

## 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

- 1.0.3 (latest) — 2016-03-15
- 1.0.2 — 2015-10-08
- 1.0.1 — 2015-10-08

## README

# get-ports

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Finds multiple open ports after your specified base ports, and below the max range. 

Unlike [getport](https://github.com/mikeal/getport) or [get-port](https://github.com/sindresorhus/get-port), this is useful for situations where you need multiple servers to run on open ports.

If not all ports could be found, the error callback is triggered.

## Install

```sh
npm install get-ports --save
```

## Example

The resulting `ports` array is parallel to your input (base) ports.

For example, if port `8000` and `9966` are already in use:

```js
var getPorts = require('get-ports')

getPorts([ 8000, 9966 ], function (err, ports) {
  if (err) throw new Error('could not open servers')
  
  console.log(ports)
  //=> [ 8001, 9967 ]
})
```

## Usage

[![NPM](https://nodei.co/npm/get-ports.png)](https://www.npmjs.com/package/get-ports)

#### `getPorts(basePorts, [maxPort], callback)`

For the given array of `basePorts`, tries to find the next available port from each one. This keeps track of available ports to ensure there are no conflicts in the final result.

If the finite number `maxPort` is specified, the portfinding will fail when it reaches that maximum port. Defaults to 60000.

The callback is called with `(err, ports)`, where `err` will be an Error if any of the portfindings failed (i.e. no open ports within range). If successful, `err` will be null and `ports` will be an array, parallel to `basePorts`, with the found port numbers.

## License

MIT, see [LICENSE.md](http://github.com/Jam3/get-ports/blob/master/LICENSE.md) for details.

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