CLI Command Reference
portctl commands and options cheat sheet.
Global Flags
Section titled “Global Flags”| Flag | Description |
|---|---|
-h, --help |
Print help information |
-V, --version |
Print version information |
--json |
Output response in structured JSON format |
Commands
Section titled “Commands”portctl list
Section titled “portctl list”Lists all assigned ports and real-time listening socket statuses.
portctl list [--json]portctl get [app]
Section titled “portctl get [app]”Resolves the deterministic port assigned to a project. If [app] is omitted, automatically detects from portctl.toml, package.json, Cargo.toml, etc.
portctl get [app] [--json]portctl init
Section titled “portctl init”Initializes a declarative portctl.toml configuration file in the project root.
portctl initportctl init --name my-service --port 4005 --domain service.example.comportctl run -- <command...>
Section titled “portctl run -- <command...>”Executes any arbitrary command with $PORT injected into the environment.
portctl run -- npm run devportctl run -- uvicorn main:app --port $PORTportctl check [target]
Section titled “portctl check [target]”Probes socket status and retrieves process ownership (PID, process name, memory RSS).
portctl check # Check current projectportctl check 3000 # Check specific portportctl check my-app # Check by service nameportctl check 3000 --jsonportctl assign <app>
Section titled “portctl assign <app>”Registers an application with fixed or auto-incremented port allocations. If portctl.toml is present, automatically populates defaults.
portctl assign redis -f 6379 -s local --desc "Redis Cache Server"portctl assign web-frontend -d frontend.example.com --jsonportctl assign web-frontend -d frontend.example.com
### `portctl kill <target>`Terminates processes occupying a socket using progressive SIGTERM -> SIGKILL escalation.
```bashportctl kill 3000portctl kill web-frontendportctl kill 5432 --force # Override protected infrastructure port guardrailportctl rename <old_name> <new_name>
Section titled “portctl rename <old_name> <new_name>”Renames a registered application while preserving its exact allocated port, ingress tunnel, and metadata.
portctl rename word-frequency-app wordradarportctl rename legacy-api modern-api --jsonportctl delete <app> (alias: remove)
Section titled “portctl delete <app> (alias: remove)”Unregisters an application from the port registry and releases its port back to the allocation pool.
portctl delete old-serviceportctl remove retired-worker --jsonportctl wait [target]
Section titled “portctl wait [target]”Blocks script execution until a port or application service is listening and ready.
portctl wait 3000 # Wait for port 3000 (TCP default)portctl wait web-api -m http -t 15 # Wait for HTTP 2xx/3xx on web-api port within 15sportctl wait --path /health --json # Probe custom HTTP path with JSON outputportctl expose <app>
Section titled “portctl expose <app>”Automates Cloudflare Tunnel ingress configuration and daemon reload.
portctl expose my-app -d myapp.example.comportctl unexpose <app>
Section titled “portctl unexpose <app>”Revokes Cloudflare Tunnel ingress routes and reloads the daemon.
portctl unexpose my-appportctl doctor
Section titled “portctl doctor”Performs system health audit on permissions, lockfiles, and dangling ingress rules.
portctl doctor # Audit onlyportctl doctor --fix # Automatically repair anomaliesportctl doctor --json # Machine-readable reportportctl env
Section titled “portctl env”Generates .env variables or shell export statements.
portctl env -w # Write PORT into .env or .env.localportctl env -e # Output 'export PORT=...'portctl completion <shell>
Section titled “portctl completion <shell>”Generates shell autocompletion script.
portctl completion zshportctl completion bashportctl completion fish