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

is-tcp-port-used

v1.0.2

Published

Check if a TCP port is in use, wait until free or used. Zero dependencies, async/await, TypeScript.

Downloads

284

Readme

is-tcp-port-used

npm version npm downloads license

Check if a TCP port is in use, wait until free or used

A modern, zero-dependency replacement for tcp-port-used. Built with TypeScript, async/await, and a clean options-based API.

Why not tcp-port-used?

| | tcp-port-used | is-tcp-port-used | |---|---|---| | Last updated | 2020 | 2026 | | Dependencies | 2 (debug, is2) | 0 | | TypeScript | No (needs @types/) | Built-in | | API style | Positional args | Options object | | ESM support | No | Dual ESM/CJS | | Source size | 369 lines | ~70 lines | | Patterns | var, callbacks, manual deferreds | async/await |

tcp-port-used hasn't been updated since 2020, drags in unnecessary dependencies, and has a broken bugs URL in its own package.json. This package does the same thing with zero dependencies and full TypeScript support.

Install

npm install is-tcp-port-used

Usage

Check if a port is in use

import { check } from "is-tcp-port-used";

const inUse = await check({ port: 3000 });
console.log(inUse); // true or false

With custom host and timeout

const inUse = await check({
  port: 3000,
  host: "192.168.1.100",
  timeout: 5000,
});

Wait until a port is used

Useful for waiting on a server to start:

import { waitUntilUsed } from "is-tcp-port-used";

await waitUntilUsed({
  port: 3000,
  retryInterval: 250, // check every 250ms (default)
  maxWait: 10000,      // give up after 10s (default)
});

console.log("Server is up!");

Wait until a port is free

Useful for waiting on a server to shut down:

import { waitUntilFree } from "is-tcp-port-used";

await waitUntilFree({
  port: 3000,
  retryInterval: 250,
  maxWait: 10000,
});

console.log("Port is free!");

API

check(options): Promise<boolean>

| Option | Type | Default | Description | |--------|------|---------|-------------| | port | number | — | Port to check (required) | | host | string | "127.0.0.1" | Host to connect to | | timeout | number | 2000 | Connection timeout in ms |

waitUntilUsed(options): Promise<void>

waitUntilFree(options): Promise<void>

Same options as check, plus:

| Option | Type | Default | Description | |--------|------|---------|-------------| | retryInterval | number | 250 | Time between checks in ms | | maxWait | number | 10000 | Max wait time in ms before rejecting |

CommonJS

const { check, waitUntilUsed, waitUntilFree } = require("is-tcp-port-used");

TypeScript

Types are included — no need to install @types/is-tcp-port-used.

Migrating from tcp-port-used

- const tcpPortUsed = require("tcp-port-used");
- tcpPortUsed.check(3000, "127.0.0.1")
+ import { check } from "is-tcp-port-used";
+ check({ port: 3000, host: "127.0.0.1" })

- tcpPortUsed.waitUntilFree(3000, 500, 10000)
+ waitUntilFree({ port: 3000, retryInterval: 500, maxWait: 10000 })

No more guessing which positional argument is which.

License

MIT - Piyush Jha