Skip to main content

A cross-platform command-line tool to inspect and kill processes using specific ports

Project description

๐Ÿ”ช kport - Cross-Platform Port Inspector and Killer

A simple, powerful command-line tool to inspect and kill processes using specific ports on Windows, Linux, and macOS.

โœจ Features

  • ๐Ÿ” Inspect ports - Find which process is using a specific port
  • ๐Ÿ”Ž Inspect by process name - Find all processes matching a name and their ports
  • ๐Ÿ”ช Kill processes - Terminate processes using specific ports
  • ๐Ÿ“‹ List all ports - View all listening ports and their processes
  • ๐ŸŽฏ Kill by process name - Kill all processes matching a name (e.g., "node", "python")
  • ๐Ÿ”ฅ Kill multiple ports - Kill processes on multiple ports at once
  • ๐ŸŽจ Colorized output - Easy-to-read colored terminal output
  • โœ… Confirmation prompts - Safety confirmation before killing processes
  • ๐ŸŒ Cross-platform - Works on Windows, Linux, and macOS
  • ๐Ÿš€ Easy to use - Simple command-line interface

๐Ÿ“ฆ Installation

Quick Install (Once Published to PyPI)

pip install kport

Install from GitHub

pip install git+https://github.com/farman20ali/port-killer.git

Install from Source

# Clone the repository
git clone https://github.com/farman20ali/port-killer.git
cd port-killer

# Install
pip install .

Install for Development

# Install in editable mode
pip install -e .

After installation, kport will be available globally in your terminal.

Run Without Installing

# Run directly with Python
python kport.py -h

๐Ÿ“– For detailed installation instructions, see INSTALL.md

๐Ÿš€ For publishing instructions, see PUBLISH.md

๐Ÿš€ Usage

Inspect a port

Find out which process is using a specific port:

kport -i 8080

Example output:

๐Ÿ” Inspecting port 8080...

โœ“ Port 8080 is being used by PID 12345

Process Information:
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PID: 12345
Image Name: node.exe
Session Name: Console
Mem Usage: 45,678 K

Inspect by process name

Find all processes matching a name and see what ports they're using:

kport -ip node

Example output:

๐Ÿ” Inspecting processes matching 'node'...

Found 3 connection(s) for processes matching 'node':

PID        Process                   Port       State          
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
12345      node.exe                  3000       LISTENING      
                                     3001       LISTENING      
12346      node.exe                  8080       LISTENING      

โœ“ Total processes found: 2
โœ“ Total connections: 3

Kill a process on a port

Terminate the process using a specific port:

kport -k 8080

Example output:

๐Ÿ”ช Attempting to kill process on port 8080...

Found PID 12345 using port 8080

Process to be terminated:
PID: 12345
Image Name: node.exe

Are you sure you want to kill this process? (y/N): y

โœ“ Successfully killed process 12345
Port 8080 is now free.

List all listening ports

View all active listening ports and their associated processes:

kport -l

Example output:

๐Ÿ“‹ Listing all active ports...

Protocol   Local Address            State           PID       
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
TCP        0.0.0.0:80               LISTENING       1234      
TCP        0.0.0.0:443              LISTENING       1234      
TCP        0.0.0.0:3000             LISTENING       5678      
TCP        0.0.0.0:8080             LISTENING       9012

Kill by process name

Kill all processes matching a specific name:

kport -kp node

Example output:

๐Ÿ”ช Killing all processes matching 'node'...

Found 3 process(es) matching 'node':
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  PID 12345: node.exe
  PID 12346: node.exe
  PID 12347: node.exe

Are you sure you want to kill 3 process(es)? (y/N): y

โœ“ Killed PID 12345
โœ“ Killed PID 12346
โœ“ Killed PID 12347

โœ“ Successfully killed 3/3 process(es)

Kill multiple ports at once

Kill processes on multiple ports simultaneously:

kport -ka 3000 3001 3002

Example output:

๐Ÿ”ช Killing processes on 3 port(s)...

Found processes on 3 port(s):
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Port 3000: PID 12345 (node.exe)
  Port 3001: PID 12346 (node.exe)
  Port 3002: PID 12347 (python.exe)

Are you sure you want to kill 3 process(es)? (y/N): y

โœ“ Killed process on port 3000 (PID 12345)
โœ“ Killed process on port 3001 (PID 12346)
โœ“ Killed process on port 3002 (PID 12347)

โœ“ Successfully killed 3/3 process(es)
Ports freed: 3000, 3001, 3002

Show help

kport -h

Show version

kport -v

๐Ÿ“š Command-Line Options

Option Long Form Description
-i PORT --inspect PORT Inspect which process is using the specified port
-ip NAME --inspect-process NAME Inspect all processes matching the given name and their ports
-k PORT --kill PORT Kill the process using the specified port
-kp NAME --kill-process NAME Kill all processes matching the given name
-ka PORT [PORT ...] --kill-all PORT [PORT ...] Kill processes on multiple ports at once
-l --list List all listening ports and their processes
-v --version Show version information
-h --help Show help message

๐Ÿ› ๏ธ Requirements

  • Python 3.6 or higher
  • No external dependencies (uses only Python standard library)

Platform-specific tools

The tool uses platform-native commands:

  • Windows: netstat, tasklist, taskkill
  • Linux/macOS: lsof, ps, kill

These tools are typically pre-installed on all platforms.

๐Ÿ”ง Development

Clone and setup

git clone https://github.com/farman20ali/port-killer.git
cd port-killer

# Install in development mode
pip install -e .

Run tests

# Test inspecting a port
kport -i 80

# Test listing ports
kport -l

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

โš ๏ธ Important Notes

  • Administrator/sudo privileges: Killing processes may require elevated privileges on some systems
  • Port validation: Port numbers must be between 1 and 65535
  • Safety: The tool asks for confirmation before killing any process
  • Multiple processes: If multiple processes use the same port, the first one found will be shown/killed

๐Ÿ› Troubleshooting

"Permission denied" errors

On Linux/macOS, you may need to run with sudo:

sudo kport -k 80

On Windows, run your terminal as Administrator.

Port not found

Make sure the port number is correct and that a process is actually using it. Use kport -l to see all active ports.

Color output not working on Windows

Colors should work on Windows 10 and later. If you're on an older version, colors may not display correctly.

๐Ÿ“ง Contact

Your Name - your.email@example.com

Project Link: https://github.com/yourusername/port-killer


Made with โค๏ธ for developers who are tired of hunting down processes

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

kport-1.0.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

kport-1.0.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file kport-1.0.0.tar.gz.

File metadata

  • Download URL: kport-1.0.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for kport-1.0.0.tar.gz
Algorithm Hash digest
SHA256 221a91acfd2ae0f98de4447b01667a4b09d69f6352fe2c35b484a2158f9b6801
MD5 3a289d25dc7b054c6bee92e991314e3c
BLAKE2b-256 290c35da852923881c43481864977072698ee57455d74fef94da652d37e814e2

See more details on using hashes here.

File details

Details for the file kport-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kport-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for kport-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e19d41101518990087c1a05daabb3505b30ac1a374708918919a37da4e90952e
MD5 8f0b82dd114dee3a0061bbd970987656
BLAKE2b-256 cdebedc8a776e5c0af718569d2143b3bb096bf6433a75cfd46325ac246f1f04a

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