Skip to content

kabeier/DevServer-Sentinel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

DevPorts --- Developer Port Scanner & Killer

Why This Exists

Modern development environments frequently leave ports occupied after crashes, failed Docker runs, backend restarts, or improperly terminated dev servers. Common frameworks like Node, Vite, Flask, FastAPI, React, Angular, Postgres, Redis, and others typically use predictable ports.

Instead of manually running:

  • lsof -i :PORT
  • ss -ltnp
  • kill -9 PID

This utility provides a fast interactive interface to:

  • Scan common developer ports
  • See what is currently running
  • Kill specific processes
  • Kill all matching processes at once
  • Rescan instantly

It removes friction from everyday development workflows.


What It Does

  • Scans a predefined list of common development ports
  • Shows:
    • Port number
    • PID
    • User
    • Command
  • Provides a numbered interactive menu
  • Attempts graceful shutdown (SIGTERM) first
  • Falls back to SIGKILL (-9) if needed
  • Uses ss and lsof for reliable detection

Installation

  1. Create a bin directory (if needed):
mkdir -p ~/bin
  1. Save the script as:
~/bin/devports
  1. Make it executable:
chmod +x ~/bin/devports
  1. Ensure ~/bin is in your PATH:
echo $PATH

If not present, add it:

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Usage

Run:

devports

If PATH is not configured:

~/bin/devports

Menu Options

  • number → Kill that specific process
  • a → Kill all listed processes
  • r → Rescan ports
  • q → Quit

Default Ports Scanned

The script scans common development ports including:

  • 3000--3009 (React / Vite / Node)
  • 4000
  • 4173
  • 4200 (Angular)
  • 5000--5001 (Flask / FastAPI)
  • 5173--5179 (Vite)
  • 5432--5433 (Postgres)
  • 6379 (Redis)
  • 8000--8005 (Python dev servers)
  • 8080--8085 (Generic dev / Docker)
  • 9000--9001
  • 9229 (Node debugger)
  • 27017 (MongoDB)

You can modify the PORTS=(...) array inside the script to customize.


Why Not Just Use kill -9?

While kill -9 works, it forces immediate termination without cleanup. This script attempts a graceful shutdown first, then escalates only if required.

This reduces: - Corrupted temporary files - Dirty database shutdowns - Port reuse issues - Unflushed logs


Dependencies

  • ss (iproute2)
  • lsof
  • bash

Most Linux distributions include these by default.


Ideal Use Case

  • Active backend/frontend development
  • Docker workflows
  • Local database servers
  • Rapid testing environments
  • When ports get "stuck"

Philosophy

Development should be frictionless.

If a port is blocking your flow, you shouldn't have to hunt for it manually.

This tool keeps you focused on building instead of debugging process state.

About

A small port closing utility script for Linux developers who constantly lose track of running dev servers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages