# is-port-available

> Check if the requested port is available or instead used

Latest version **0.1.5** (published 2017-11-16) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install is-port-available
pnpm add is-port-available
yarn add is-port-available
bun add is-port-available
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2017-11-16 |
| First published | 2017-09-07 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | colxi |
| Maintainers | colxi |
| Keywords | port available, port check, port busy, is port available , isportavailable, port free, is port free |

## Links

- npm: https://www.npmjs.com/package/is-port-available
- Repository: https://github.com/colxi/is-port-available
- Homepage: https://github.com/colxi/is-port-available#readme
- Issues: https://github.com/colxi/is-port-available/issues
- npm.io page: https://npm.io/package/is-port-available

## Recent versions

- 0.1.5 (latest) — 2017-11-16
- 0.1.4 — 2017-09-07
- 0.1.3 — 2017-09-07
- 0.1.2 — 2017-09-07
- 0.1.0 — 2017-09-07

## README

# is-port-available (nodejs)

```(async) isPortAvailable()``` : Will test the requested port, resolving the returned Promise with ```true```, when port **IS AVAILABLE**, and ```false``` when **NOT AVAILABLE**.
> NOTE: When port is **NOT AVAILABLE**, the fail reason (err.code | err) can be checked reading ```isPortAvailable.lastError``` property (wich is reset automatically before each call to isPortAvailable)

### Methods

```isPortAvailable( port )```  (function) => Expects an integer, and returns a Promise that resolves in true|false

```isPortAvailable.lastError``` (string) => Contains the last call error (EADDRINUSE, EACCES...)

### Installation

Use npm to install the module :
```$ npm install --save is-port-available```


[NPM Package Page](https://www.npmjs.com/package/is-port-available)

### Usage
Example of a simple port avaiability test via ```Promise.then()```:
```javascript
	const isPortAvailable = require('is-port-available');

	var port = 80;
	isPortAvailable(port).then( status =>{
		if(status) console.log('Port ' + port + ' IS available!');
		else{
			console.log('Port ' + port + ' IS NOT available!');
			console.log('Reason : ' + isPortAvailable.lastError);
		}
	});
```
Example Using ```await``` inside an ```async``` self invoking function :
```javascript
	const isPortAvailable = require('is-port-available');

	(async function(){
		var port = 80;
		var status = await isPortAvailable(port);

		if(status) console.log('Port ' + port + ' IS available!');
		else{
			console.log('Port ' + port + ' IS NOT available!');
			console.log('Reason : ' + isPortAvailable.lastError);
		}

	})()
```

## Licence

GPL

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