PortTree

A zero-dependency Python CLI for resolving port collisions, zombie process trees, and Docker socket masks in local development and CI.

EADDRINUSE crashes and orphaned sockets disrupt development workflows and CI suites when servers fail to unbind ports cleanly.

A blind 'kill -9 <PID>' often fails because supervisor processes respawn workers immediately, or the socket is masked behind docker-proxy.

PortTree parses /proc/net/tcp and socket inodes on Linux, queries iphlpapi via ctypes on Windows, and traces the complete process tree up to init.

Zero third-party dependencies; direct OS kernel syscalls and memory tables provide instant socket-to-process attribution across Linux, Windows, and macOS.

Implements graceful two-phase termination (SIGTERM followed by SIGKILL timeout) and machine-readable JSON output for CI pre-flight checks.

Available on PyPI as porttree. It provides ASCII tree inspection, port availability assertions, and safe socket cleanup without requiring psutil.

Direct kernel interface parsing eliminates compilation overhead and wheel building issues in minimal Alpine and CI containers.