pid-port
Get the ID of the process that uses a certain port
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pid-port 
SYNC missed versions from official npm registry.

pid-port

Get the ID of the process that uses a certain port

Install

npm install pid-port

Usage

import {portToPid} from 'pid-port';

try {
	console.log(await portToPid(8080));
	//=> 1337

	const pids = await portToPid([8080, 22]);

	console.log(pids.get(8080));
	//=> 1337

	console.log(pids.get(22));
	//=> 12345
} catch (error) {
	console.log(error);
	//=> 'Could not find a process that uses port `8080`'
}

API

portToPid(port)

Get the process ID for a port.

Returns a Promise<number | undefined> (integer) with the process ID.

port

Type: number (integer)

The port to look up.

portToPid(ports)

Get the process IDs for multiple ports.

Returns a Promise<Map<number, number>> (integer) with the port as key and the process ID as value.

ports

Type: number[] (integer)

The ports to look up.

pidToPorts(pid)

Get the ports for a process ID.

Returns a Promise<Set<number>> with the ports.

pid

Type: number

The process ID to look up.

pidToPorts(pids)

Get the ports for multiple process IDs.

Returns a Promise<Map<number, Set<number>>> with the process ID as the key and the ports as value.

pids

Type: number[]

The process IDs to look up.

allPortsWithPid()

Get all ports with their process ID.

Returns a Promise<Map<number, number>> (integer) with the port as key and the process ID as value.

Related

  • fkill-cli - Uses this package to let you kill the process that occupies a certain port
  • pid-cwd - Find the working directory of a process from its process ID

Current Tags

  • 1.0.2                                ...           latest (a year ago)

7 Versions

  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           2 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |