Modern QA2026Port Management — tiles
Log inJoin
11 / 55 · 19 Linux & Command Line · Permissions and Processes← prev⊞ allnext →☰ Read as one page

2.5Port Management

"Port already in use" is one of the most common QA frustrations. Here is how to diagnose and fix it.

# Find what is using port 3000 (your test server won't start)
lsof -i :3000
# COMMAND  PID  USER  TYPE  DEVICE  NODE  NAME
# node     1234  qa   IPv4  12345   TCP   *:3000 (LISTEN)

# Alternative command
ss -tlnp | grep 3000
# LISTEN  0  128  *:3000  *:*  users:(("node",pid=1234,fd=15))

# Find all listening ports
ss -tlnp

# Find processes using a port range
lsof -i :3000-3100

Killing Processes

# Graceful shutdown (SIGTERM) -- lets the process clean up
kill 1234

# Force kill (SIGKILL) -- immediate termination, use as last resort
kill -9 1234

# Kill by name
pkill -f "node server.js"

# Kill all processes matching a pattern
pkill -f "playwright"

# Kill the process using a specific port
kill $(lsof -t -i :3000)

Always try graceful shutdown first. kill -9 does not let the process clean up (close database connections, save state, release locks). Use it only when kill does not work.