惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
博客园 - 司徒正美
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
小众软件
小众软件
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
A
About on SuperTechFans
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
B
Blog RSS Feed
G
Google Developers Blog
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Stop Wasting Tabs: How to background your dev servers and...
The Builder · 2026-06-01 · via DEV Community
Cover image for Stop Wasting Tabs: How to background your dev servers and kill them with one command

The Builder

If you are building full-stack apps (like a Django backend mated to a React/Vite frontend), you know the struggle of the "Locked Terminal."

You run npm run dev or python manage.py runserver, and suddenly that terminal pane is completely hijacked. To run another command, you're forced to open a brand-new tab, split your screen, or context-switch out of your flow.

Worse yet, when you hit Ctrl+C to close those servers, they sometimes leave behind "zombie processes" that stubbornly hold onto your ports (8000 or 5173), forcing you to hunt down PIDs just to restart your environment.

On my Linux setup, I got tired of managing a million tabs. Here is how to run your servers cleanly in the background and terminate them instantly using a single custom Zsh function.

The Trick: The Power of the Ampersand (&)

Most developers run their servers in the foreground. But if you append a simple & to your startup command, Linux pushes that process into the background, giving you your terminal prompt back immediately.

Instead of this:

npm run dev
# ...terminal is now locked...

Do this:

npm run dev &

What happens next? Your server spins up, its logs will still print gracefully to your screen so you can track errors, but your terminal prompt stays active. You can keep typing commands in the exact same window!

The Problem: How do you kill a background server?

Because the server is running in the background, hitting Ctrl+C won't stop it anymore. If you want to free up ports 5173 (Vite) and 8000 (Django) for your next session, you need a surgical cleanup tool.

Let’s automate this by adding a helper function to your shell configuration.

Step 1: Add the Automation to your ~/.zshrc

Open your shell config file (vim ~/.zshrc) and paste this custom function at the bottom:

# Stop background development servers and instantly free ports
stop-dev() {
    echo "🛑 Shutting down development stack..."

    # 1. Forcefully kill any process holding onto our frontend/backend ports
    sudo fuser -k 5173/tcp 8000/tcp 2>/dev/null

    # 2. Verify the ports are completely clear
    echo "🔍 Verifying port status..."
    if ! lsof -i :8000 -i :5173 > /dev/null; then
        echo "✅ Ports 8000 and 5173 are completely clear and ready!"
    else
        echo "⚠️ Warning: Some processes are still lingering."
    fi
}

Save and close the file, then reload your shell environment:

source ~/.zshrc

The workflow

Now your development loop becomes incredibly smooth and single-tab friendly:

  1. Start your stack:
npm run dev & python manage.py runserver &

(Both servers are now running concurrently in the background of a single window!)

  1. Keep working: Use that same terminal prompt to run Git commands, create migrations, or check logs.
  2. Nuke it when done: When you're ready to wrap up your session, simply type:
stop-dev

You'll prompt for sudo password once if your cache is expired, and fuser will cleanly clear both ports out of memory instantly.

How do you manage your local full-stack setups? Let me know in the comments below!