Kagex/Guides
Port ForwardSpeed & Workflows · 3 min read

Safely Preview AI-Built Web Apps via Loopback Port Forwarding

Let Playwright or your browser verify agent-built UI changes on 127.0.0.1 while keeping the server containerized inside its isolated Ubuntu microVM.

Bind interface
127.0.0.1 only (never 0.0.0.0)
CLI syntax
sandboxctl port <id> <guest_port>
Background cmd
sandboxctl exec <id> -d -- <cmd>
Run and preview a sandboxed web app
sandboxctl exec "$ID" -d -- "npm run dev -- --port 3000"
sandboxctl port "$ID" 3000
# -> Prints http://127.0.0.1:NNNNN

Key Engineering Points · One-Way Workspace Sync, 3-Way Apply & Undo

All 10 key points →
  • 1Host folders are never shared or mounted into guest microVMs — virtio-fs and 9p mounts are intentionally disabled.
  • 2Workspace synchronization moves strictly one way (host -> VM) over explicit AF_VSOCK tar streams checked by guest/files.
  • 3Running rm -rf /workspace inside a sandbox has zero effect on the developer's repository on disk.
  • 4Before every sandbox_exec, incremental host file changes delta-sync automatically into guest /workspace.
  • 5Diff previews compare VM edits cleanly against repository git HEAD without mutating host git refs, index, or checked-out branches.
  • 6Applying approved patches uses temporary git merge-file 3-way merges rather than blind file overwrites.

Loopback-Only Binding Guarantee

Exposed ports bind strictly onto host 127.0.0.1 ephemeral ports rather than LAN interfaces (0.0.0.0), preventing untrusted dev servers inside VMs from accepting external Wi-Fi traffic.

Agent Self-Verification Loops

AI agents can start a backend server via sandbox_exec, map it with sandbox_port, run integration curls cleanly, and tear everything down on sandbox_destroy.

Inspect this architecture live in 3D

Step through MCP ingress, Ghost Secrets, CoW blades, and run sandboxctl commands interactively in your browser.

Frequently Asked Questions

No. Kagex binds strictly to 127.0.0.1.