Phuriwaj

Kill Process by Port Number

Quick commands to kill whatever is occupying a given port.

Why / When to Use

Use when a dev server (Next.js, Django, etc.) fails to start because the port is already in use.

Core Concept / Commands

macOS / Linux โ€” one-liner

lsof -ti:<PORT> | xargs kill -9
# Example: lsof -ti:3000 | xargs kill -9

macOS / Linux โ€” see PID first

lsof -ti:<PORT>   # get PID
kill -9 <PID>

Windows

netstat -ano | findstr :<PORT>
taskkill /PID <PID> /F

Key Options / Variants

Common dev ports: 3000 (Next.js), 8000 (Django), 4000 (misc), 5173 (Vite).

Gotchas

  • kill -9 sends SIGKILL โ€” process cannot catch or ignore it. Safe for dev servers.
  • On macOS, some system processes on privileged ports (<1024) require sudo.

Source

Conversation: โ€œKill process on port 3000โ€ โ€” 2026-05-30; also Next.js 15 turbopack config: turbopack: true moved from experimental.turbopack to top-level in next.config.ts.