ephemeral-port-reserve
Bind to an ephemeral port, force it into the TIME_WAIT state, and unbind it.
Decision gist · record as of 2026-08-14
Yes, if you need race-free ephemeral port allocation in parallel or containerized scenarios where port 0 doesn't work. The package is lightweight, has no dependencies, carries a permissive license, and is actively maintained. Install it only if you hit the specific problem it solves; it's not a general-purpose utility.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a Unix-like system with socket support; behavior and grace period (default 60 seconds on Linux) are OS-dependent.
- No runtime dependencies and low install friction.
- Repository is active with recent commits (last commit 2026-04-02) and has been maintained since 2016, though the latest release was 2021-02-11.
License · maintenance · safety
MIT (permissive) — MIT license is permissive and imposes no restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2021-02-11 (2010 days) · last repo commit 2026-04-02 · 70 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 90,223 downloads/mo, #13,610 on PyPI
Alternatives
Verify before relying
pip install ephemeral-port-reserve
from ephemeral_port_reserve import reserve
port = reserve()
print(port) # Returns an available port number- Whether the package works reliably on Windows or other non-Linux systems.
- Current test coverage and whether the race-free guarantee holds under high concurrency.
- Whether the 60-second TIME_WAIT grace period is configurable or system-dependent only.
What it is and what it does
ephemeral-port-reserve solves the problem of allocating unused network ports when the standard "port 0 trick" fails or is unreliable. Some applications like mysqld or Docker interpret port 0 specially rather than letting the kernel choose a free port, and Docker's port allocation can race under parallelism. This package provides a race-free alternative by binding to an ephemeral port, forcing it into TIME_WAIT state, and unbinding it—reserving that port so the kernel won't reuse it for a grace period (typically 60 seconds on Linux), while still allowing subprocesses to bind to it explicitly if they use SO_REUSEADDR.
It's typically used in test suites, containerized deployments, and parallel service startup scenarios where you need to guarantee port availability without hard-coding. The package has no runtime dependencies, supports Python 2.7 and 3.5 through 3.8, and is maintained as a small, focused utility.
Use it for
- Running multiple Docker containers in parallel without port conflicts by reserving ports before container startup.
- Allocating ports for parallel test services in CI/CD pipelines where port 0 is unreliable.
- Starting multiple instances of mysqld or similar daemons that don't honor port 0 as a kernel-allocation signal.
- Ensuring port availability in containerized test environments where standard ephemeral allocation races.
- Scripting port reservation for subprocess startup when you need to pass the port number to child processes.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need race-free ephemeral port allocation in parallel or containerized scenarios where port 0 doesn't work.
The package is lightweight, has no dependencies, carries a permissive license, and is actively maintained. Install it only if you hit the specific problem it solves; it's not a general-purpose utility.
Install
ephemeral-port-reserve on PyPI
Before you install
No runtime dependencies and low install friction. Repository is active with recent commits (last commit 2026-04-02) and has been maintained since 2016, though the latest release was 2021-02-11.
Requires a Unix-like system with socket support; behavior and grace period (default 60 seconds on Linux) are OS-dependent.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install ephemeral-port-reserve
from ephemeral_port_reserve import reserve
port = reserve()
print(port) # Returns an available port number
Verify before relying
- Whether the package works reliably on Windows or other non-Linux systems.
- Current test coverage and whether the race-free guarantee holds under high concurrency.
- Whether the 60-second TIME_WAIT grace period is configurable or system-dependent only.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 2,010 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 90,223 / month, #13,610 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: ephemeral_port_reserve-1.1.4-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “ephemeral port allocation”
- ephemeral-port-reserveReserves an ephemeral port reliably and race-free by binding, forcing…
- port-forport-for finds and remembers unused TCP localhost ports, useful for…
- portpickerFinds and returns an unused network port on the local host, available…
Give your agent the search over MCP, or paste the wish link into any chat.
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
psutil retrieves real-time information about running processes and system resources (CPU, memory, disks, network, sensors) across multiple operating systems, enabling system monitoring, process profiling, and resource management.
pyOpenSSL wraps OpenSSL's SSL/TLS functionality for Python, providing high-level connection objects and certificate handling through a Python-friendly interface around OpenSSL's cryptographic operations.
uvloop is a drop-in replacement for Python's built-in asyncio event loop, implemented in Cython and using libuv, that accelerates async I/O operations.
execnet lets you spawn and communicate with Python interpreters across local processes, remote hosts, and different platforms, using a simple API for task distribution and inter-process messaging.
However, the aging maintenance status (275 days since last release) means you should verify it meets your concurrency and performance needs before committing to a…
PyZMQ provides Python bindings for ZeroMQ (ØMQ), a lightweight messaging library that enables fast, asynchronous communication between distributed processes and applications.
See also port-for · portend · portpicker · grpcio-gcp · cpuset-py3 · jaraco.net · docker-compose · atomicwrites · wait-for-it · argbind