npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clean-port

v0.1.2

Published

Library to clear a TCP port by terminating the process that uses it.

Readme

clean-port

Clear a TCP port by terminating the process that currently owns it. Works on macOS, Linux, and Windows.

Requirements

  • macOS or Linux: lsof must be available
  • Windows: netstat must be available (included with Windows)

Install

npm install clean-port -g

Quick start

Library

const { clearPort } = require("clean-port");

const result = clearPort(3000);
console.log(result);

Force cleanup if the port remains in use:

const { clearPort } = require("clean-port");

const result = clearPort(3000, { force: true });
console.log(result);

CLI

npx clean-port 3000
npx clean-port 3000 --force
npx clean-port 3000 --signal SIGKILL

CLI options

  • -s, --signal kill signal (default SIGTERM)
  • -f, --force use SIGKILL if still in use
  • --wait-ms delay between checks (default 300)
  • --retries number of rechecks (default 5)

API

clearPort(port, options)

  • port number or numeric string
  • options.signal kill signal (default SIGTERM)
  • options.waitMs delay between checks in ms (default 300, non-negative)
  • options.retries number of rechecks (default 5, non-negative integer)
  • options.force use SIGKILL if still in use (default false)

Returns:

{ cleared: boolean, status: "cleared" | "force_cleared" | "already_clear" | "still_in_use", pids: number[], remainingPids: number[] }

Best practices

  • Start with SIGTERM and allow a short wait before retrying.
  • Use force only when you can safely terminate the process.
  • Run as the same user that owns the process; use sudo only when required.
  • Avoid auto-restart supervisors while cleaning a port in dev scripts.
  • For CI/automation, set waitMs and retries explicitly.

Troubleshooting

If the port is still in use after SIGTERM, retry with SIGKILL or use elevated permissions:

sudo npx clean-port 3000 --signal SIGKILL