skillfed

portend

TCP port monitoring and discovery

portend v3.2.1 890.0K downloads/30d#4,806 on PyPI9
Permissive license MIT Active released

What it is and what it does

Portend is a lightweight TCP port monitoring library that lets you wait for a port to become occupied (bound by a listener) or free (unbound), with configurable timeouts. It's commonly used in test setup, service orchestration, and deployment scripts where you need to verify that a service has started or that a port is available before binding to it.

The package provides a simple API with two main functions—`occupied()` and `free()`—plus utilities like `find_available_local_port()` to discover an unused port and a lower-level `Checker` class for more direct control. It can also be invoked as a command-line tool via `python -m portend`, making it useful in shell scripts and CI/CD pipelines. The only runtime dependency is tempora, keeping the installation footprint minimal.

Use it for:

  • Wait for a service to start up in integration tests before running test suites that depend on it
  • Find an available local port to bind a test server without port conflicts
  • Verify port availability in deployment or orchestration scripts before starting a service
  • Monitor a remote port (e.g., a database or API server) to detect when it becomes available after a restart
  • Implement health checks in CI/CD pipelines that need to confirm a service is listening before proceeding

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Portend monitors TCP ports to check whether they are bound (occupied) or free, and can find available local ports for binding.

Yes. Portend solves a common, specific problem (TCP port state checking) with a minimal dependency footprint, active maintenance, no known vulnerabilities, and a permissive license. It's well-suited for test automation, service orchestration, and deployment workflows. Install it if you need to wait for ports or discover available ones in Python or shell scripts.

Install

portend on PyPI

pip

pip install portend

uv

uv add portend

poetry

poetry add portend

Installing portend

Before you install

Low install friction: pure Python wheel with a single runtime dependency (tempora). Actively maintained with recent commits; last release was 2025-05-29 and the repository shows ongoing activity.

License in practice

MIT license is permissive and places no significant restrictions on use, modification, or distribution in commercial or private projects.

Quickstart

pip install portend

import portend

# Wait for a port to be occupied (with 3 second timeout)
portend.occupied('www.google.com', 80, timeout=3)

# Or find an available local port
port = portend.find_available_local_port()
print(port, "is available for binding")

Requires Python 3.9 or later.

Verify before relying

  • Whether the package handles IPv6 addresses reliably (the description mentions '::1' but does not detail IPv6 support scope)
  • Performance characteristics when monitoring many ports concurrently or in rapid succession

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — tempora
Maintenance actively maintained — 442 days since the last release
Last repo commit
First released
Downloads 889,978/month — #4,806 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: portend-3.2.1-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: Only

Tags

tcp port monitoringcheck if port is openwait for port to be freefind available portport binding checkerport availability detectiontcp port state checker
port-monitoringtcp-utilitiestest-infrastructure

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

wait-for-it

A command-line tool that waits for one or more…

permissive · top 15,000 on PyPI

port-for

port-for finds and remembers unused TCP…

permissive · top 5,000 on PyPI

ephemeral-port-reserve

Reserves an ephemeral port reliably and…

permissive · top 15,000 on PyPI

portpicker

Finds and returns an unused network port on the…

permissive · top 5,000 on PyPI

websockify

Translates WebSocket connections to normal TCP…

copyleft · top 15,000 on PyPI

pydivert

PyDivert is a Python binding for the WinDivert…

copyleft · top 15,000 on PyPI

pmd-net-proto

Parses, assembles, and validates network…

copyleft · top 15,000 on PyPI

waiting

Waiting is a lightweight library for polling a…

permissive · top 15,000 on PyPI

polling2

Polling2 lets you wait for a function to return…

permissive · top 5,000 on PyPI

tox-docker

A tox plugin that manages Docker container…

permissive · top 15,000 on PyPI