Process Inspection
top, htop, and lsof for diagnosing port conflicts, runaway Node processes, and resource pressure on Linux hosts running Node.js APIs.
Search across all documentation pages
top, htop, and lsof for diagnosing port conflicts, runaway Node processes, and resource pressure on Linux hosts running Node.js APIs.
Quick-reference recipe card - copy-paste ready.
# Port in use (EADDRINUSE)
lsof -i :3000
# or
ss -tlnp 'sport = :3000'
# Graceful stop
kill -TERM <PID>
sleep 5
kill -KILL <PID> # only if still running
# CPU/memory snapshot
top -b -n 1 | head -20
ps aux | grep nodeWhen to reach for this:
Error: listen EADDRINUSE: address already in use :::3000$ npm run dev
Error: listen EADDRINUSE: address already in use :::3000
$ lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 48291 dev 23u IPv6 0t... 0t0 TCP *:3000 (LISTEN)
$ kill -TERM 48291
$ npm run dev # succeedskill -TERM (SIGTERM) so Fastify/Express shutdown hooks runkill -9 only when process ignores SIGTERM after 10s# Find pod
kubectl get pods -l app=orders-api
# OOM and restart reason
kubectl describe pod orders-api-7f8b9c-xyz | grep -A5 "Last State"
# Top inside container (if image has procps)
kubectl exec -it orders-api-7f8b9c-xyz -- top -b -n 1 | head -15
# Process list
kubectl exec orders-api-7f8b9c-xyz -- ps aux# Typical describe excerpt
Last State: Terminated
Reason: OOMKilled
Exit Code: 137memory.limit to Node --max-old-space-size if setps aux | grep node
# node dist/server.js ← API port 3000
# node dist/workers/email.js ← no listen port, high CPU during batchlsof -i :3000htop
# F5 tree view - see parent container PID 1
# F6 sort by MEM% or CPU%
# Filter: F4 type "node"| Tool | Best for |
|---|---|
| lsof | Which PID owns port 3000 |
| ss | Socket summary without installing lsof |
| top | Quick CPU/mem snapshot (every server) |
| htop | Interactive sorting and tree view |
| kubectl describe | OOMKilled, restart count, limits |
Use ss -tlnp or install lsof in debug image only - not production Dockerfile unless approved.
Yes. libuv thread pool and V8 workers create threads. Worry about memory RSS and event loop lag, not thread count alone.
No. Kubernetes restarts the pod. Scale down replica or kubectl delete pod for clean restart after drain.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 16, 2026