Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coreybutler/porthog
Identify which process is using a specific port.
https://github.com/coreybutler/porthog
conflict detection management port port-conflict portscanner
Last synced: 7 days ago
JSON representation
Identify which process is using a specific port.
- Host: GitHub
- URL: https://github.com/coreybutler/porthog
- Owner: coreybutler
- License: mit
- Created: 2016-09-05T22:14:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T21:26:10.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T05:43:25.536Z (7 months ago)
- Topics: conflict, detection, management, port, port-conflict, portscanner
- Language: JavaScript
- Homepage:
- Size: 412 KB
- Stars: 28
- Watchers: 3
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# porthog
This module identifies which application is using a specified
port, providing the process name and PID. Works for Windows, OSX, and most flavors of Linux/Unix that support the `lsof`, `ss`, or `netstat` operations.## CLI Implementation
`npm install -g porthog`
`porthog 33649 80`
Outputs:
```sh
PORT PID PROCESS
--------------------------------------------------
33649 43580 node-webkit Helper (cbutler)
80 - -
```## API Implementation Example
```js
const porthog = require('porthog')
const data = porthog(80)console.log(data.user, 'is running', data.process + ' (PID ' + data.pid + ') on port 80.')
// Output
// cbutler is running node.exe (PID 656) on port 80.
```_This operation may require elevated/root privileges._
## Uses
We're using this in [Fenix Web Server](http://fenixwebserver.com)
to resolve port conflicts. When a user tries to launch a server
on an occupied port, we use porthog to determine which app is
"hogging" the port and provide the user an option to stop/kill the offending process.We also use this in combination with [node-windows](https://github.com/coreybutler/node-windows),
[node-mac](https://github.com/coreybutler/node-mac), and
[node-linux](https://github.com/coreybutler/node-linux) to
create background processes that monitor ports and notify
users what's running on the ports they want to use.There are certainly many other uses. If you use this, be
warned that some operating systems (Windows in particular)
may require elevated permissions. This is dependent on
each user's environment, so it's not always predictable. To
get around this, we've found the aforementioned node-* modules
to be useful when creating daemons (especially the [binary utilities and extra scripts](https://github.com/coreybutler/node-windows/tree/master/bin) for Windows). For Electron/NW.js apps,
[sudo-prompt](https://github.com/jorangreef/sudo-prompt) has been
quite helpful.# License
MIT