Skip to main content

See what's listening on a TCP port and free it - cross-platform, zero dependencies.

Project description

portvac

See what's listening on a TCP port - and free it. The "port already in use" error costs every developer a minute of lsof / netstat / taskkill archaeology. portvac lists who's on a port in one command, then vacates it on confirm. Cross-platform, zero dependencies.

pip install portvac
portvac             # list every listening TCP port
portvac 3000        # show what's on 3000, then kill it (asks first)
portvac 3000 -k     # kill without asking (scripts / CI)
portvac 3000 -s KILL   # SIGKILL instead of the default SIGTERM

Node shop? npx portvac 3000 -k works too - same tool, same behaviour.

Why

"Port 3000 is already in use" - and now you're pasting lsof -i :3000 into Stack Overflow for the fourth time this week.

lsof flags differ from netstat which differs from Windows taskkill. You remember none of them under pressure. portvac is the one command that works the same on macOS, Linux, and Windows: look first, kill second, never silent.

How it works

  1. List - shells out to the platform's own tool (lsof / ss / netstat) to read listening sockets. No daemon, no network.
  2. Show - prints a clean table: port, pid, process name, address, family.
  3. Vacate - on a port argument, asks y/N, then sends a signal (default TERM) to the owning pid(s). -k skips the prompt.

Nothing is installed system-wide and no data leaves your machine.

Usage

portvac                       List every TCP port currently listening
portvac <port>                Show what's on <port>, then kill it (asks first)
portvac <port> --list         Show only, don't kill
portvac <port> -k             Kill without confirmation
portvac <port> -s KILL        Send KILL instead of TERM
portvac --json [<port>]       Machine-readable output (great for piping)

  -k, --force         Kill without confirmation
  -l, --list          List only; never kill
  -s, --signal <SIG>  TERM (default), KILL, INT, QUIT, HUP
      --json          Emit JSON; suppresses colors and prompts
  -v, --version

JSON

$ portvac --json 3000
{
  "port": 3000,
  "listeners": [
    { "port": 3000, "pid": 12345, "name": "node", "address": "0.0.0.0", "protocol": "tcp", "family": "ipv4" }
  ]
}

Platform notes

Platform Lookup Kill
macOS / BSD lsof -iTCP -sTCP:LISTEN -P -n os.kill(pid, sig)
Linux ss -tlnp (falls back to netstat -tlnp) os.kill(pid, sig)
Windows netstat -ano + tasklist taskkill /PID <pid> /F /T

On Windows there's no POSIX signal hierarchy, so portvac force-terminates (taskkill /F). To see another user's processes you may need elevated privileges, same as the underlying tools.

Exit codes

Code Meaning
0 listed, or killed successfully
1 nothing listening / port not in use / aborted
2 error (bad args, tool missing, kill failed)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

portvac-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

portvac-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file portvac-0.1.0.tar.gz.

File metadata

  • Download URL: portvac-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for portvac-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d77546f616c0e5f3cbd7472356548595ea7224556a5da7ffb7dd7b5b2eeb1384
MD5 26c1aabd70684bfbd5b10fd97723ae9b
BLAKE2b-256 e79777451ebfd9b24c9e9bf5c94cba696f62918c261fcaf898a0ed93c3aea754

See more details on using hashes here.

File details

Details for the file portvac-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: portvac-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for portvac-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7049516374b5b5b17abace41da23e379ebc9c85c2ebd1b55d23fcf6adb89503e
MD5 b02a2eaf0d71425caa6ca4454f0e1755
BLAKE2b-256 fbad96990efeb668d942264ece12257abc19dfc65e389335ac9b15a2c3b80fb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page