Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

find-pid-from-port

ksathyanm296MIT0.1.0

Find the pid(s) of a process on a given port

netstat, lsof, net, stat, port, tcp, udp, activity, pid, pids

readme

find-pid-from-port

Test windows status Test macOS status Test linux status

npm version Node.js version npm downloads Minified size Known vulnerabilities

Find the pid(s) of a process on a given port

Install

$ npm install find-pid-from-port

Usage

const findPidFromPort = require("find-pid-from-port")

const example = async () => {
  try {
    const pids = await findPidFromPort(8017)
    console.log(pids.all)
    //=> [1234, 5678]

    console.log(pids.tcp)
    //=> [1234]

    console.log(pids.udp)
    //=> [5678]
  } catch (error) {
    console.log(error)
    //=> "Couldn't find a process with port `8017`"
  }
}
example()

API

findPidFromPort(port)

port

Type: number

Port to lookup.