Skip to main content

Overview

Sandboxes can expose services to the internet via public tunnels. Your application must bind to IPv6 to be reachable.

IPv6 requirement

Internally, sandboxes use IPv6 networking. Your server must bind to :: (IPv6 all interfaces), not just 0.0.0.0 or 127.0.0.1.

Flask (Python)

Express (Node.js)

FastAPI (Python)

Go HTTP server

Exposing a service

Use sandbox.expose(port) to get the public URL:

Port requirements

  • Port must be a positive integer
  • No default port; you must specify it explicitly
  • Common ports: 3000 (Node), 5000 (Flask), 8000 (FastAPI), 8080 (Go)

Complete example

Checking server readiness

Multiple services

Expose multiple ports from the same sandbox:

Troubleshooting

Connection refused

If you get connection refused errors:
  1. Check IPv6 binding: Ensure your app binds to ::, not 0.0.0.0
  2. Verify process is running: Use pgrep or ps aux
  3. Check logs: Read server logs for startup errors
  4. Wait for readiness: Some servers take time to start

Missing publicAccessUrlTemplate

If expose() throws an error about missing template:

Port already in use

Best practices

  • Always bind IPv6: Use :: as the host in your server configuration
  • Use background mode: Start servers with { background: true }
  • Redirect logs: Capture stdout/stderr to files for debugging
  • Wait for readiness: Poll or sleep before calling expose()
  • Handle errors: Wrap expose() in try-catch and check for template
  • Clean up: Kill background processes before terminating sandbox