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 :3000into 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
- List - shells out to the platform's own tool (
lsof/ss/netstat) to read listening sockets. No daemon, no network. - Show - prints a clean table: port, pid, process name, address, family.
- Vacate - on a port argument, asks
y/N, then sends a signal (defaultTERM) to the owning pid(s).-kskips 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
Metadata
Release files for portvac 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| portvac-0.1.0.tar.gz | 12.2 kB | Without provenance | Details for portvac-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| portvac-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for portvac-0.1.0-py3-none-any.whl |
Total release size: 22.4 kB
Release files / portvac-0.1.0.tar.gz
| Download URL | portvac-0.1.0.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d77546f616c0e5f3cbd7472356548595ea7224556a5da7ffb7dd7b5b2eeb1384
|
|
BLAKE2b-256 checksum How to use checksums |
e79777451ebfd9b24c9e9bf5c94cba696f62918c261fcaf898a0ed93c3aea754
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.7
|
Release files / portvac-0.1.0-py3-none-any.whl
| Download URL | portvac-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7049516374b5b5b17abace41da23e379ebc9c85c2ebd1b55d23fcf6adb89503e
|
|
BLAKE2b-256 checksum How to use checksums |
fbad96990efeb668d942264ece12257abc19dfc65e389335ac9b15a2c3b80fb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.7
|
Security for portvac 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.