# Bonsai Image Studio — Host Conflict Log

Host: debian-ai (192.168.1.50), Debian 13, RTX 2080 Ti.

## Issue
`scripts/serve.sh` exits with `[ERR] Port 8000 already in use (backend).` because Open Terminal occupies `:8000`.

## Resolution
Launch with `BACKEND_PORT=8001`:
```bash
cd ~/Bonsai-Image-Demo
BACKEND_PORT=8001 FRONTEND_PORT=3000 BONSAI_FRONTEND_PROD=1 bash scripts/serve.sh
```

## Readiness Checks
```bash
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000/   # 200
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8001/backends  # 200
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8001/docs        # 200
```

## Teardown
```bash
pkill -f "Bonsai-Image-Demo|scripts/serve.sh|scripts.local_backend|next dev|next start" 2>/dev/null || true
fuser -k 3000/tcp 2>/dev/null || true
fuser -k 8001/tcp 2>/dev/null || true
```

## Notes
- `serve.sh` looks for `:8000` and `:3000` as hardcoded defaults; only override via env vars or it will fail fast.
- Frontend.js API routes default to `http://127.0.0.1:8000` in source; `serve.sh` overrides via `NEXT_PUBLIC_BACKEND_URL`.
- Backend root `/` is 404 by design; use `/backends` and `/docs`.
- For LAN/Tailscale access, ensure the phone is on the same LAN or Tailscale and the host firewall allows the chosen ports.
