# portscanner

> Asynchronous port scanner for Node.js

Latest version **2.2.0** (published 2018-05-14) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2018-05-14 |
| First published | 2011-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/portscanner) |
| Module format | CommonJS |
| Node | >=0.4 |
| Dependencies | 2 |
| Unpacked size | 22.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 297 |
| Maintainers | baalexander, laggingreflex, shinnn, smassa |
| Keywords | portscanner, port, scanner, checker, status |

## Links

- npm: https://www.npmjs.com/package/portscanner
- Repository: https://github.com/baalexander/node-portscanner
- Issues: https://github.com/baalexander/node-portscanner/issues
- npm.io page: https://npm.io/package/portscanner

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^2.6.0
- [is-number-like](https://npm.io/package/is-number-like.md) ^1.0.3

## 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
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2018-05-14
- 2.1.1 — 2016-11-24
- 2.1.0 — 2016-11-22
- 1.2.0 — 2016-11-22
- 1.1.1 — 2016-11-21
- 1.1.0 — 2016-11-19
- 1.0.0 — 2014-06-22
- 0.2.3 — 2014-04-10
- 0.2.2 — 2014-02-06
- 0.2.1 — 2014-02-05
- 0.2.0 — 2014-01-07
- 0.1.3 — 2012-06-20
- 0.1.2 — 2011-11-30
- 0.1.1 — 2011-11-18
- 0.1.0 — 2011-08-30

## README

# portscanner

[![npm](https://img.shields.io/npm/v/portscanner.svg)](https://www.npmjs.com/package/portscanner)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

The portscanner module is
an asynchronous JavaScript port scanner for Node.js.

Portscanner can check a port,
or range of ports,
for 'open' or 'closed' statuses.

[Looking for maintainer](https://github.com/baalexander/node-portscanner/issues/25)!

## Install

```bash
npm install portscanner
```

## Usage

A brief example:

```javascript
var portscanner = require('portscanner')

// Checks the status of a single port
portscanner.checkPortStatus(3000, '127.0.0.1', function(error, status) {
  // Status is 'open' if currently in use or 'closed' if available
  console.log(status)
})

// Find the first available port. Asynchronously checks, so first port
// determined as available is returned.
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function(error, port) {
  console.log('AVAILABLE PORT AT: ' + port)
})

// Find the first port in use or blocked. Asynchronously checks, so first port
// to respond is returned.
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', function(error, port) {
  console.log('PORT IN USE AT: ' + port)
})

// You can also pass array of ports to check
portscanner.findAPortInUse([3000, 3005, 3006], '127.0.0.1', function(error, port) {
  console.log('PORT IN USE AT: ' + port)
})

// And skip host param. Default is '127.0.0.1'
portscanner.findAPortNotInUse(3000, 4000, function(error, port) {
  console.log('PORT IN USE AT: ' + port)
})

// And use promises
portscanner.findAPortNotInUse(3000, 4000).then(function(port) {
  console.log('PORT IN USE AT: ' + port)
})
```

The example directory contains a more detailed example.

## Test

```sh
npm test
```

## Future

Please create issues or pull requests
for port scanning related features
you'd like to see included.

## License (MIT)

[MIT](LICENSE)

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