Skip to content
Back to skills

Collection

ASecurity

Stop local Flask server running on port 8080. Kills process cleanly using lsof or PID file. Use when stopping local Python development server.

  • 24 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
devopspythonbashnodeflasktestingdebuggingapi

Works with

  • terminal
  • api

Security analysis

A96/100
  • mediumUses curl or wget to download content

Pro scans all 21 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add mattnigh/skills_collection --skill collection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collection
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/mattnigh-collection-26999693/badge)](https://www.skillsdirectory.com/skills/mattnigh-collection-26999693)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: py-stop-local
description: Stop local Flask server running on port 8080. Kills process cleanly using lsof or PID file. Use when stopping local Python development server.
---

# Python Stop Local Server

## Overview

Stops a locally running Flask server by killing the process on port 8080. Works for both foreground and background server instances.

## When to Use

Invoke this skill when the user:
- Asks to "stop the server"
- Wants to "kill the Flask app"
- Says "stop local server"
- Mentions shutting down the Python server
- Needs to stop before deploying or restarting

## Prerequisites

- Server must be running on port 8080
- Either a PID file exists (server.pid) or lsof command available
- macOS or Linux system

## Instructions

### Option 1: Using stop.sh Script

1. Navigate to the server directory:
   ```bash
   cd path/to/server/imp/py
   ```

2. Run the stop script:
   ```bash
   ./stop.sh
   ```

3. The script will:
   - Read PID from server.pid file
   - Kill the process
   - Clean up PID file
   - Report success

### Option 2: Manual Stop by Port

If no script available:
```bash
lsof -ti:8080 | xargs kill
```

This finds and kills any process using port 8080.

### Option 3: Foreground Server

If running in foreground mode:
- Press **Ctrl+C** in the terminal

## Expected Output

**Using stop.sh**:
```
πŸ›‘ Stopping Firefly server...
βœ… Server stopped (PID: 12345)
```

**Manual stop**:
```
# Silent if successful, or:
kill: 12345: No such process (if already stopped)
```

## How It Works

**stop.sh script**:
```bash
if [ -f server.pid ]; then
    PID=$(cat server.pid)
    kill $PID
    rm server.pid
    echo "Server stopped"
else
    # Fallback: kill by port
    lsof -ti:8080 | xargs kill
fi
```

**lsof method**:
- `lsof -ti:8080`: Lists process IDs using port 8080
- `xargs kill`: Pipes PIDs to kill command
- Clean termination (SIGTERM)

## Verification

Check server is stopped:
```bash
# Try to curl - should fail
curl http://localhost:8080/api/ping

# Check port is free
lsof -ti:8080
# (no output = port free)
```

## Common Issues

**"No such process"**:
- Server already stopped (not an error)
- PID file may be stale
- Delete server.pid if it exists

**"Operation not permitted"**:
- Server running as different user
- Try with sudo (not recommended)
- Check process owner: `ps aux | grep python3`

**Port still in use after stop**:
- Process didn't terminate cleanly
- Force kill: `lsof -ti:8080 | xargs kill -9`
- Wait a few seconds for port to free

**server.pid file not found**:
- Server wasn't started with start.sh
- Use manual stop: `lsof -ti:8080 | xargs kill`
- Or kill foreground server with Ctrl+C

## Kill Signals

**SIGTERM** (default `kill`):
- Polite termination request
- Allows cleanup
- Process can catch and handle
- Used by stop.sh

**SIGKILL** (`kill -9`):
- Immediate termination
- No cleanup possible
- Cannot be caught
- Use as last resort

Always try SIGTERM first.

## When to Stop

**Before deploying**:
```bash
./stop.sh
# Make changes
./start.sh
```

**Before testing different port**:
```bash
./stop.sh
# Edit app.py to use different port
python3 app.py
```

**Before remote deployment**:
```bash
./stop.sh  # Stop local
# Deploy to remote with py-deploy-remote
```

**When switching modes**:
```bash
# Stop background server
./stop.sh
# Start foreground for debugging
python3 app.py
```

## Port Conflicts

If port 8080 is used by another app:

**Find what's using port**:
```bash
lsof -i:8080
```

**Output shows**:
```
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
python3  12345 user   3u  IPv4  0x...  0t0  TCP *:8080 (LISTEN)
```

**Kill specific process**:
```bash
kill 12345
```

## Cleanup

The stop script cleans up:
- Terminates Python process
- Removes server.pid file
- Frees port 8080

Logs (server.log) are preserved for review.

## Safe to Call Repeatedly

This operation is idempotent:
- Safe to call if server already stopped
- Won't error on missing PID
- Graceful failure on no process found

## Integration with Other Skills

**Restart workflow**:
1. py-stop-local
2. Make code changes
3. py-start-local

**Deploy workflow**:
1. py-stop-local (local server)
2. py-deploy-remote (to production)
3. py-start-local (resume local development)

## Alternative: Process Manager

For production, use a process manager:
- **supervisord**: Automatic restart, logging
- **systemd**: System-level service
- **pm2**: Node.js-based process manager

But for development, manual start/stop is simpler.

## Notes

- Only stops server on current machine
- Does not affect remote deployments
- Port 8080 becomes available immediately after stop
- Logs remain in server.log for review
- PID file is automatically cleaned up

Files in this skill

  • 0Chan-smc__claude-code-workflow-lab__claude__skills__frontend-dev-guidelines__SKILL.md15.1 KB
  • 17hz__nextjs-template__claude__skills__example-skill__SKILL.md316 B
  • 1ambda__dataops-platform__claude__skills__context-synthesis__SKILL.md3.5 KB
  • 1natsu172__dotfiles__claude__skills__git-analysis__SKILL.md5.4 KB
  • 1natsu172__dotfiles__claude__skills__github-pr-best-practices__SKILL.md7.7 KB
  • 23Maestro__prospect-pipeline__claude__skills__npid-fastapi-skill.md26.1 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-javascript__SKILL.md15.7 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-python__SKILL.md17.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-expression-syntax__SKILL.md9.4 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-mcp-tools-expert__SKILL.md12.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-node-configuration__SKILL.md16.6 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-workflow-patterns__SKILL.md11.2 KB
  • 3x-Projetos__claude-memory-framework__claude__skills__scientist__SKILL.md14.8 KB
  • 5MinFutures__futures-arena__claude__skills__migration-tracker__SKILL.md16.2 KB
  • 5MinFutures__futures-arena__claude__skills__planning-guidelines__SKILL.md11.8 KB
  • 92Bilal26__TaskPilotAI__claude__skills__assessment-builder__SKILL.md17.5 KB
  • 92Bilal26__TaskPilotAI__claude__skills__book-scaffolding__SKILL.md19.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__code-validation-sandbox__SKILL.md6.2 KB
  • 92Bilal26__TaskPilotAI__claude__skills__exercise-designer__SKILL.md18.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__learning-objectives__SKILL.md24.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…