{"id":20596605,"url":"https://github.com/suhailroushan13/killport-npm","last_synced_at":"2026-04-21T05:34:27.083Z","repository":{"id":154423908,"uuid":"632178757","full_name":"suhailroushan13/killport-npm","owner":"suhailroushan13","description":"killport-npm package would take a port number as an argument and then find the process using that port. After identifying the process, it would terminate it, effectively \"killing\" the port and freeing it up for other processes to use.","archived":false,"fork":false,"pushed_at":"2026-03-20T15:41:08.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-21T07:23:22.997Z","etag":null,"topics":["bash","killport","lsof","npm","process"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/killport-npm","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suhailroushan13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-24T21:56:28.000Z","updated_at":"2026-03-20T15:41:04.000Z","dependencies_parsed_at":"2024-09-29T06:16:13.430Z","dependency_job_id":null,"html_url":"https://github.com/suhailroushan13/killport-npm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/suhailroushan13/killport-npm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhailroushan13%2Fkillport-npm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhailroushan13%2Fkillport-npm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhailroushan13%2Fkillport-npm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhailroushan13%2Fkillport-npm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suhailroushan13","download_url":"https://codeload.github.com/suhailroushan13/killport-npm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhailroushan13%2Fkillport-npm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32079065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","killport","lsof","npm","process"],"created_at":"2024-11-16T08:17:47.080Z","updated_at":"2026-04-21T05:34:27.076Z","avatar_url":"https://github.com/suhailroushan13.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# killport-npm\n\n[![npm version](https://img.shields.io/npm/v/killport-npm.svg)](https://www.npmjs.com/package/killport-npm)\n[![Node.js](https://img.shields.io/node/v/killport-npm.svg)](https://nodejs.org/)\n\nCLI that finds the process **listening on a TCP port** and terminates it. Works on **Windows**, **macOS**, **Ubuntu / Linux**, and **WSL** (same code path as Linux).\n\n## Table of contents\n\n- [Requirements](#requirements)\n- [Install (quick reference)](#install-quick-reference)\n- [Install on Windows](#install-on-windows)\n- [Install on macOS](#install-on-macos)\n- [Install on Ubuntu (and most Debian-based Linux)](#install-on-ubuntu-and-most-debian-based-linux)\n- [Install on WSL (Windows Subsystem for Linux)](#install-on-wsl-windows-subsystem-for-linux)\n- [How to use (proper workflow)](#how-to-use-proper-workflow)\n- [Usage summary](#usage-summary)\n- [Package lifecycle (npm / pnpm / yarn)](#package-lifecycle-npm--pnpm--yarn)\n- [Authors](#authors)\n\n## Requirements\n\n- **Node.js 18+** (from [nodejs.org](https://nodejs.org), your OS package manager, or a version manager such as **nvm** / **fnm** / **n**)\n\nPackage managers supported:\n\n- **npm** (ships with Node)\n- **pnpm** — same package; lifecycle scripts (`preinstall` / `postinstall`) run the same as with npm\n- **Yarn** — same package; use **Yarn Classic (1.x)** `yarn global add` for a global CLI, or **`yarn dlx`** (Yarn 2+) for a one-off run (same idea as `npx` / `pnpm dlx`)\n\nPlatform tools used:\n\n| OS | Resolution | Kill |\n|----|------------|------|\n| macOS | `lsof` | `kill` |\n| Linux / WSL | `ss`, then `lsof` | `kill` |\n| Windows | `netstat` | `taskkill` |\n\nKilling processes owned by another user may require **Administrator** (Windows) or **sudo** (Unix).\n\n---\n\n## Install (quick reference)\n\n| Goal | npm | pnpm | Yarn |\n|------|-----|------|------|\n| Global CLI (`killport` on your PATH) | `npm install -g killport-npm` | `pnpm add -g killport-npm` | `yarn global add killport-npm` (Classic **1.x** only; ensure [Yarn global bin is on `PATH`](https://classic.yarnpkg.com/lang/en/docs/cli/global/)) |\n| One-off, no global install | `npx killport-npm \u003cport\u003e` | `pnpm dlx killport-npm \u003cport\u003e` | `yarn dlx killport-npm \u003cport\u003e` (**Yarn 2+**; for Yarn 1 use `npx` or a global install) |\n\nAfter a global install, run:\n\n```bash\nkillport --help\nkillport 3000\n```\n\nIf `killport` is not found, your global bin directory is not on `PATH`. See the OS sections below.\n\n---\n\n## Install on Windows\n\n1. **Install Node.js 18+**  \n   - Download from [nodejs.org](https://nodejs.org), or e.g. `winget install OpenJS.NodeJS.LTS` (build may vary).\n\n2. **Optional: install pnpm**  \n   - Follow [pnpm installation](https://pnpm.io/installation) (e.g. `npm install -g pnpm` or the standalone script).\n\n3. **Install this package globally**\n\n   ```powershell\n   npm install -g killport-npm\n   ```\n\n   or\n\n   ```powershell\n   pnpm add -g killport-npm\n   ```\n\n   or (Yarn Classic 1.x)\n\n   ```powershell\n   yarn global add killport-npm\n   ```\n\n4. **PATH**  \n   - **npm:** global binaries usually live under `%AppData%\\npm`. The Node installer often adds this to PATH.  \n   - **pnpm:** run `pnpm setup` once and follow the printed instructions so the pnpm global bin is on PATH.  \n   - **Yarn Classic:** run `yarn global bin` and add that folder to PATH if `killport` is not found.  \n   - Open a **new** terminal after changing PATH.\n\n5. **Permissions**  \n   - If `taskkill` fails for a system or other user’s process, open **PowerShell** or **Command Prompt** as **Administrator** and run `killport \u003cport\u003e` again.\n\n6. **Use without global install**\n\n   ```powershell\n   npx killport-npm 3000\n   pnpm dlx killport-npm 3000\n   yarn dlx killport-npm 3000\n   ```\n\n---\n\n## Install on macOS\n\n1. **Install Node.js 18+** (official installer, Homebrew `brew install node`, or nvm/fnm).\n\n2. **Install globally**\n\n   ```bash\n   npm install -g killport-npm\n   # or\n   pnpm add -g killport-npm\n   # or (Yarn Classic 1.x)\n   yarn global add killport-npm\n   ```\n\n3. **PATH**  \n   - If `killport` is not found, ensure your npm global prefix is on PATH (`npm prefix -g` → `bin` next to it). For pnpm, run `pnpm setup` if you use pnpm’s default store layout. For Yarn Classic, add Yarn’s global bin to PATH (see `yarn global bin`).\n\n4. **Permissions**  \n   - If you get permission errors killing another user’s process, use `sudo killport \u003cport\u003e` (only when necessary).\n\n5. **One-off**\n\n   ```bash\n   npx killport-npm 3000\n   pnpm dlx killport-npm 3000\n   yarn dlx killport-npm 3000\n   ```\n\n`lsof` is available by default on macOS.\n\n---\n\n## Install on Ubuntu (and most Debian-based Linux)\n\n1. **Install Node.js 18+**  \n   - e.g. [NodeSource](https://github.com/nodesource/distributions), **nvm**, or your distro’s packages if the version is ≥ 18.\n\n2. **Tools**  \n   - `ss` is in **`iproute2`** (usually preinstalled): `sudo apt update \u0026\u0026 sudo apt install -y iproute2`  \n   - Optional fallback: `sudo apt install -y lsof`\n\n3. **Install globally**\n\n   ```bash\n   npm install -g killport-npm\n   # or\n   pnpm add -g killport-npm\n   # or (Yarn Classic 1.x)\n   yarn global add killport-npm\n   ```\n\n4. **PATH**  \n   - Same idea as macOS: ensure the global `bin` directory npm/pnpm/Yarn uses is on your `PATH` (restart the shell after changes).\n\n5. **Permissions**  \n   - Use `sudo killport \u003cport\u003e` if the listener is owned by root or another user.\n\n6. **One-off**\n\n   ```bash\n   npx killport-npm 3000\n   pnpm dlx killport-npm 3000\n   yarn dlx killport-npm 3000\n   ```\n\n---\n\n## Install on WSL (Windows Subsystem for Linux)\n\nWSL runs a **Linux** distro; install **Node inside that distro** (not only on Windows), then use the **same commands as Ubuntu / Linux** above.\n\n1. Open your WSL terminal (e.g. Ubuntu).\n2. Install Node 18+ there (nvm is a common choice).\n3. Run:\n\n   ```bash\n   npm install -g killport-npm\n   # or\n   pnpm add -g killport-npm\n   # or (Yarn Classic 1.x)\n   yarn global add killport-npm\n   ```\n\n**Important:** `killport` in WSL only sees processes **in that Linux environment**. If a server is bound on the **Windows** host, kill it from **Windows** (PowerShell/CMD) with a Windows install of Node + `killport`, or stop the process from Task Manager.\n\nEnsure `iproute2` / `ss` (and optionally `lsof`) are installed in the distro, as on Ubuntu.\n\n---\n\n## How to use (proper workflow)\n\n1. **See what would be killed** (safe):\n\n   ```bash\n   killport 3000 --dry-run\n   ```\n\n2. **Kill the listener** (default is forceful: `SIGKILL` on Unix, `taskkill /F` on Windows):\n\n   ```bash\n   killport 3000\n   ```\n\n3. **Try graceful shutdown first** (then force on Unix if needed; on Windows tries `taskkill` without `/F`, then `/F`):\n\n   ```bash\n   killport 3000 --graceful\n   ```\n\n4. **Interactive mode** (only when stdin is a TTY): run `killport` with no arguments and enter the port when prompted.\n\n5. **Help:**\n\n   ```bash\n   killport --help\n   ```\n\n---\n\n## Usage summary\n\n```bash\nkillport \u003cport\u003e [options]\n```\n\n| Option | Meaning |\n|--------|---------|\n| `--dry-run` | Print PID(s) that would be killed; do not kill |\n| `--graceful` | `SIGTERM` / `taskkill` without `/F` first (Unix then `SIGKILL` if needed) |\n| `--help`, `-h` | Help |\n\nSame flags work with runners, for example:\n\n```bash\nnpx killport-npm 8080 --dry-run\npnpm dlx killport-npm 8080 --dry-run\nyarn dlx killport-npm 8080 --dry-run\n```\n\n---\n\n## Package lifecycle (npm / pnpm / yarn)\n\n`preinstall` and `postinstall` run for **npm**, **pnpm**, and **yarn** installs of this package.\n\n| Script | When | Purpose |\n|--------|------|---------|\n| `preinstall` | Before install | Ensures Node ≥ 18 |\n| `postinstall` | After install | Short usage hint (WSL hint when detected) |\n| `prepublishOnly` | Before `npm publish` | Syntax-checks CLI and lib files (maintainers) |\n\n---\n\n## Authors\n\n- [Suhail Roushan](https://github.com/suhailroushan13)\n\n## Links\n\n[![GitHub](https://img.shields.io/badge/github-000?style=for-the-badge\u0026logo=github\u0026logoColor=white)](https://github.com/suhailroushan13)\n\n[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/suhailroushan13/)\n\n[![twitter](https://img.shields.io/badge/twiiter-00acee?style=for-the-badge\u0026logo=twitter\u0026logoColor=white)](https://twitter.com/0xsuhailroushan)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuhailroushan13%2Fkillport-npm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuhailroushan13%2Fkillport-npm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuhailroushan13%2Fkillport-npm/lists"}