# openport

> Finds open network ports.

Latest version **0.0.6** (published 2018-12-08) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install openport
pnpm add openport
yarn add openport
bun add openport
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2018-12-08 |
| First published | 2012-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6.0 |
| Dependencies | 0 |
| Unpacked size | 96.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Joe Ferner |
| Maintainers | joeferner |
| Keywords | port, network, open |

## Links

- npm: https://www.npmjs.com/package/openport
- Repository: https://github.com/joeferner/node-openport
- Homepage: https://github.com/joeferner/node-openport#readme
- Issues: https://github.com/joeferner/node-openport/issues
- npm.io page: https://npm.io/package/openport

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

- 0.0.6 (latest) — 2018-12-08
- 0.0.5 — 2018-04-05
- 0.0.4 — 2015-06-23
- 0.0.3 — 2012-04-02
- 0.0.2 — 2012-02-28
- 0.0.1 — 2012-02-22

## README

# Deprecated use [portfinder](https://github.com/indexzero/node-portfinder)

# openport

Finds open network ports.

## Installation

```bash
$ npm install openport
```

## Quick Examples

```javascript
var op = require('openport'),
    http = require('http');

// find an open port
op.find(function(err, port) {
  if(err) { console.log(err); return; }
  // yea! we have an open port.
});

// find two open ports, choosing from 1024, 1025, 1026, 1028
op.find(
  {
    ports: [ 1024, 1025, 1026, 1028 ],
    count: 2
  },
  function(err, ports) {
    if(err) { console.log(err); return; }
    // yea! we have two open ports.
  }
);

// find an open port between 1024 and 2000, but not 1025 or 1500
op.find(
  {
    startingPort: 1024,
    endingPort: 2000,
    avoid: [ 1025, 1500 ]
  },
  function(err, port) {
    if(err) { console.log(err); return; }
    // yea! we have an open port between 1024 and 2000, but not port 1025 or 1500.
  }
);

// create 2 http servers
op.find(
  {
    count: 2,
    createServer: function (port, callback) {
      var server = http.createServer(function (req, res) {
      });
      server.port = port; // save it for later
      server.once('error', function (ex) {
        callback(ex);
      });
      server.listen(port, function () {
        callback(null, server);
      });
    }
  }, function (err, servers) {
    if(err) { console.log(err); return; }
    // yea! we have two web servers.
  }
);
```

# API Documentation

### openport.find([options], callback)

Finds open network ports

__Arguments__

 * options - (optional) - Find options
  * startingPort - The port to start searching for an open port (default: 1024).
  * endingPort - The port to stop searching for an open port (default: 65535).
  * ports - An array of ports to search.
  * count - The number of open ports to find.
  * avoid - An array of ports to avoid.
  * createServer - A function that will try to open a server listening on the given port. Use this when you want to make sure nobody steals your ports in between calls.
 * callback(err, port/ports/servers) - Callback to be called when we have found the open ports.

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