Thanks for the help Brian !
Follow this
- cd frappe-bench #or whatever your bench directory is
- git clone GitHub - proenterprise/bench-stop: Script to stop development bench started with bench start
- mv ./bench-stop/stop.py .
- sudo rm -r ./bench-stop
python3 stop.py
3 Likes
Thank you brav
works as a workaround but its great
thanks
If anyone is still looking for this answer, I have written a decent script, that is efficient enough to stop zombie processes and stop bench processes. Here’s the script to stop bench development server:
#!/bin/bash
set -euo pipefail
################################################################################
#
# Bench Stop Script for ERPNext / Frappe Framework
# License: AGPL-3.0 (https://www.gnu.org/licenses/agpl-3.0.en.html)
# Prepared by: BatchNepal.com
#
################################################################################
BENCH_DIR="/home/frappe/frappe-bench"
# Ports: 8000 (Web), 11000 (Redis-Queue), 12000 (Redis-Cache), 13000 (Redis-Socketio), 9000 (Vite)
PORTS=(8000 11000 12000 13000 9000)
echo "⏳ Step 1: Performing Graceful pattern kill..."
# We add '|| true' so the script doesn't exit if no processes are found
pkill -15 -f "frappe.utils.bench_helper|socketio.js|redis_.*.conf|esbuild|vite" 2>/dev/null || true
sleep 2
echo "🧹 Step 2: Forceful pattern kill..."
pkill -9 -f "frappe.utils.bench_helper|socketio.js|redis_.*.conf|esbuild|vite" 2>/dev/null || true
echo "🎯 Step 3: Targeted Port Execution..."
for PORT in "${PORTS[@]}"; do
# Using || true here ensures the script continues if the port is already empty
PID=$(lsof -t -i:"$PORT" 2>/dev/null || true)
if [ ! -z "$PID" ]; then
echo "Found PID $PID still holding port $PORT. Terminating..."
kill -9 "$PID" 2>/dev/null || true
fi
done
# Clean up stale pid files
rm -f "$BENCH_DIR"/config/redis_*.pid 2>/dev/null
echo "🔍 Performing Final Verification..."
STILL_BLOCKED=0
for PORT in "${PORTS[@]}"; do
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; then
echo "❌ Port $PORT is STILL blocked."
STILL_BLOCKED=$((STILL_BLOCKED + 1))
fi
done
if [ $STILL_BLOCKED -eq 0 ]; then
echo "----------------------------------------"
echo "SUCCESS! All bench ports are free now ✅"
echo "We can run 'bench start' now 🚀"
echo "----------------------------------------"
else
echo "⚠️ Warning: $STILL_BLOCKED ports are still active. You may need to use 'sudo'."
exit 1
fi
And after saving this run these commands:
alias bench-stop=‘/home/frappe/frappe-bench/stop.sh’
source ~/.bashrc
Congrats, you can now run bench-stop from any location inside server and it will work beautifully! Suggestions are welcome.