
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Kill process running on any given port. Works with Node.js, Python, Go, Java, and any language. Zero dependencies, cross-platform support for Windows, macOS, Linux & Unix.
Kill process running on any given port. Works with Node.js, Python, Go, Java, Ruby, and ANY language. Zero dependencies, cross-platform support for Windows, macOS, Linux & Unix.
✅ Universal language support - Works with processes from ANY language ⭐ NEW
✅ Zero dependencies - Only uses Node.js built-in modules
✅ Smallest package - ~10 kB (vs competitors at 60-174 kB)
✅ Cross-platform - Windows, macOS, Linux, Unix support
✅ Port ranges - Kill ports 3000-3010 in one command
✅ Preview mode - List processes before killing
✅ TypeScript support - Full type definitions included
✅ Multiple aliases - Available as portclear, port-clear, pkill-port, etc.
✅ Flexible CLI - Positional, flag-based, and range syntax
✅ Promise-based API - Clean programmatic usage
portclear works with processes from ANY programming language:
| Language | Frameworks/Runtimes | ✓ Supported |
|---|---|---|
| JavaScript/TypeScript | Node.js, Deno, Bun, Express, Next.js, React dev servers | ✅ |
| Python | Flask, Django, FastAPI, Streamlit, Jupyter | ✅ |
| Go | Gin, Echo, Fiber, net/http | ✅ |
| Java/Kotlin | Spring Boot, Micronaut, Ktor, Tomcat | ✅ |
| Ruby | Rails, Sinatra, Puma | ✅ |
| PHP | Laravel, Symfony, built-in server | ✅ |
| Rust | Actix, Rocket, Axum | ✅ |
| C/C++ | Any HTTP server or TCP/UDP service | ✅ |
| .NET/C# | ASP.NET, Kestrel | ✅ |
| Elixir | Phoenix | ✅ |
| Any other language | If it uses a port, we can kill it! | ✅ |
How it works:
portclear doesn't care what language your process is written in. It finds what's using a port at the OS level and kills it. Simple and universal.
# Use any of these aliases:
npx portclear <port>
npx port-clear <port>
npx pkill-port <port>
npx port-stop <port>
npx port-nuke <port>
npx port-eject <port>
npm install -g portclear
npm install portclear
# Kill process on port
npx portclear 3000
# Kill port range
npx portclear 3000-3010
# List processes (preview mode)
npx portclear -l 3000
# Quiet mode for scripts
npx portclear -q 3000
Basic usage:
npx portclear 3000
Port ranges:
# Range syntax
npx portclear 3000-3010
# Flag syntax
npx portclear --from 3000 --to 3010
Multiple ports:
# Space-separated
npx portclear 3000 8080 9000
# Comma-separated
npx portclear 3000,8080,9000
List/Preview mode:
# See what's running without killing
npx portclear -l 3000
# List range of ports
npx portclear --list 3000-3010
# With verbose output
npx portclear -l 3000 -v
Quiet mode:
# Perfect for CI/CD scripts
npx portclear -q 3000
# Only shows errors, exits with proper codes
if npx portclear -q 3000; then
echo "Port cleared successfully"
fi
JSON output:
# Machine-readable output
npx portclear --json 3000
# Combine with list mode
npx portclear -l --json 3000-3010
Advanced options:
# Kill UDP process
npx portclear -p 3000 -m udp
# Verbose output with process details
npx portclear -p 3000 -v
# Kill process tree (including children)
npx portclear --tree 3000
Basic:
const portclear = require('portclear');
// Kill process on port 3000
await portclear(3000);
With options:
// New options object API (v1.0+)
await portclear(3000, {
method: 'udp', // 'tcp' or 'udp'
list: true, // Preview mode
tree: false // Kill process tree
});
// Backward compatible (still works)
await portclear(3000, 'udp');
TypeScript:
import portclear, { PortClearOptions, PortClearResult } from 'portclear';
// Full type safety
const result: PortClearResult = await portclear(3000, {
method: 'tcp',
list: true
});
if (result.pid) {
console.log(`Process ${result.name} (PID: ${result.pid}) on port ${result.port}`);
}
Error handling:
try {
await portclear(3000);
console.log('Port 3000 cleared successfully');
} catch (error) {
if (error.message.includes('Permission denied')) {
console.log('Run with sudo or as Administrator');
} else if (error.message.includes('No process running')) {
console.log('Port is already free');
} else {
console.error('Unexpected error:', error.message);
}
}
Preview before killing:
// List what's running first
const preview = await portclear(3000, { list: true });
if (!preview.error) {
console.log(`Found ${preview.name} (PID: ${preview.pid})`);
// Confirm and kill
const confirmed = await askUser('Kill this process?');
if (confirmed) {
await portclear(3000);
}
}
# Flask typically runs on 5000
npx portclear 5000
# Django on 8000
npx portclear 8000
# Kill Go app on port 8080
npx portclear 8080
# Spring Boot default port
npx portclear 8080
# Or custom port
npx portclear 9090
# Rails default port
npx portclear 3000
# Kill common Docker ports
npx portclear 2375 2376 5000 8000-8100
# Kill all common dev ports at once
npx portclear 3000-3010 5000 8000 8080 9000
const portclear = require('portclear');
const express = require('express');
async function startServer(port = 3000) {
try {
// Clear port before starting
await portclear(port, { quiet: true });
const app = express();
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
} catch (error) {
console.error('Could not start server:', error.message);
process.exit(1);
}
}
startServer();
# Use subprocess to call portclear from Python
import subprocess
def clear_port(port):
try:
subprocess.run(['npx', 'portclear', '-q', str(port)], check=True)
print(f"Port {port} cleared")
except subprocess.CalledProcessError:
print(f"Could not clear port {port}")
clear_port(5000)
{
"scripts": {
"clean": "portclear -q 3000 8080",
"prestart": "npm run clean",
"start": "node server.js",
"dev": "portclear -q 3000 && nodemon server.js",
"kill-all": "portclear 3000-9000"
}
}
| Option | Alias | Description | Default |
|---|---|---|---|
--port <port> | -p | Port number(s) - supports ranges and comma-separated | - |
--list | -l | List processes without killing (preview mode) | false |
--method <method> | -m | Protocol: tcp or udp | tcp |
--verbose | -v | Show detailed output with PIDs and process names | false |
--quiet | -q | Quiet mode - only show errors | false |
--json | - | Output results as JSON | false |
--tree | - | Kill process tree (including children) | false |
--from <port> | - | Start of port range | - |
--to <port> | - | End of port range | - |
--help | -h | Show help message | - |
portclear(port, methodOrOptions)Kill process running on specified port.
Parameters:
port (number|string) - Port number to kill (1-65535)methodOrOptions (string|object) - Either:
'tcp' or 'udp' (backward compatible)method?: 'tcp' | 'udp' - Protocol (default: 'tcp')list?: boolean - Preview mode (default: false)tree?: boolean - Kill process tree (default: false)Returns:
Promise<PortClearResult> - Result object containing:
port: number - Port numberkilled: boolean - Whether process was killedplatform: string - OS platformpid?: number - Process ID (single process)pids?: number[] - Process IDs (multiple processes)name?: string - Process nameerror?: string - Error message if failedstdout?: string - Command outputstderr?: string - Command errorslisting?: boolean - Whether this is list modeThrows:
Error - If port is invalid, no process is running, or kill operation fails| Platform | Supported | Commands Used |
|---|---|---|
| Windows | ✅ | netstat -ano, taskkill |
| macOS | ✅ | lsof, kill, ps |
| Linux | ✅ | lsof, kill, ps |
| Unix | ✅ | lsof, kill, ps |
| Feature | portclear | kill-port | killport | port-kill |
|---|---|---|---|---|
| Size (packed) | ~10 kB | ~60 kB | ~1.5 kB | ~35 kB |
| Dependencies | 0 | 2 | 2 | 0 |
| Language Universal | ✅ | ✅ | ✅ | ✅ |
| Port Ranges | ✅ | ❌ | ❌ | ❌ |
| Preview Mode | ✅ | ❌ | ❌ | ✅ |
| TypeScript | ✅ | ⚠️ (@types) | ❌ | ❌ |
| JSON Output | ✅ | ❌ | ❌ | ❌ |
| Process Tree | ✅ | ❌ | ❌ | ✅ |
| Quiet Mode | ✅ | ❌ | ❌ | ❌ |
| Cross-Platform | ✅ | ✅ | ❌ (Unix only) | ✅ |
| Active Maintenance | ✅ | ⚠️ | ❌ | ⚠️ |
Error: Permission denied for port 3000
Solution:
# macOS/Linux
sudo npx portclear 3000
# Windows (Run terminal as Administrator)
npx portclear 3000
Some applications may take time to release ports. Wait a few seconds and verify:
# List to check if process is gone
npx portclear -l 3000
# Force kill with tree option
npx portclear --tree 3000
Use list mode to see details:
# Basic info
npx portclear -l 3000
# Verbose with all details
npx portclear -l 3000 -v
# JSON for scripting
npx portclear -l --json 3000
MIT © Reshank M
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -am 'Add amazing feature')git push origin feature/amazing-feature)If you encounter any problems, please open an issue on GitHub.
This package is available under multiple names for convenience:
All aliases provide the exact same functionality.
See CHANGELOG.md for a detailed list of changes.
Made with ❤️ by developers, for developers. Works with every language. 🌍
FAQs
Kill process running on any given port. Works with Node.js, Python, Go, Java, and any language. Zero dependencies, cross-platform support for Windows, macOS, Linux & Unix.
We found that port-stop demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.