portop docs

Command line

Without flags portop opens the table. Every other mode prints and exits, so it fits in scripts, cron jobs and CI.

Flags

FlagMeaning
portop [WORDS]Open the table filtered on the words: portop 8080, portop nginx 443
--listenListening sockets only: TCP LISTEN and bound UDP
--jsonPrint one snapshot as JSON and exit
--wait PORT[/udp]Wait until something listens on the port (scripting)
--free PORT[/udp]Stop whatever listens on the port; --force, --yes
--timeout DURATIONHow long --wait (default 30s) or --free (default 5s) waits
--save-baseline, --diffRecord the listening ports, or compare with the record (baseline drift)
--compose DIRAudit a Docker Compose project's published ports (Compose audit)
--webServe the web dashboard
--watch-newDesktop notification when a new port starts listening
--interval DURATIONTable refresh interval (default 2s)
--no-dns, --no-systemd, --no-docker, --no-firewall, --no-trafficSkip that information
--config FILE, --init-configUse another configuration file; write a commented one
--baseline-path FILEUse another baseline file
--inspect-pid NPrint a process's details as JSON
--signal-pid N --expected-start TIMESignal a process only if its start time still matches; --force for SIGKILL
--versionPrint the version

JSON output

portop --json --listen | jq '.[] | select(.scope == "all") | {port: .local_port, process, firewall}'

Each row is an object with these fields; fields marked optional are left out when unknown.

FieldTypeMeaning
protocolstringTCP or UDP
local_address, local_portstring, numberBind address and port
remote_address, remote_port, remote_hostoptionalPeer and its reverse-DNS name
statestringTCP state, or UNCONN for a bound UDP socket
ipv6booleanRead from an IPv6 table
scopestringall, address or loopback
pid, process, useroptionalOwner; names are raw, not sanitized
workersoptional arrayOther processes holding the socket
systemd_unit, containeroptionalUnit or Windows service, and container
firewalloptionalallowed, restricted or blocked
rx_bytes, tx_bytesoptionalBytes received and sent by an established TCP connection
rx_bytes_per_second, tx_bytes_per_secondoptionalRates; need two samples, so they appear in the dashboard's /api/ports
cpu_percentnumberCPU use; also needs two samples

Exit codes

CodeMeaning
0Success; --diff found no change; --compose found every fixed port as expected
1Error; --wait timed out; --free could not free the port
2Invalid flags
3--diff found changes; --compose found an unused or conflicting port