Skip to main content
The Sandbox provides some basic network tools. You can run web services and expose them to the internet behind SSL-terminated endpoints. This is useful for web development, API testing, and running interactive applications with LLMs (think v0, reflex.build, etc).

Exposing Ports

You can expose ports from your Sandbox in two ways: statically at creation time, or dynamically at runtime.

Static Port Exposure

Specify ports when creating the sandbox to have them exposed immediately with public URLs:

Dynamic Port Exposure

You can also expose ports dynamically after the sandbox is created using the expose_port() method.

Expose a port

Expose multiple ports

List exposed ports/preview URLs

Network Security

Blocking Outbound Traffic

You can block all outbound network access from your Sandbox while still allowing inbound connections to exposed ports. This is useful for security-sensitive workloads or when executing untrusted code.
With block_network=True, the Sandbox can receive requests on exposed ports but cannot initiate outbound connections to external services.

Allow Lists (CIDR Ranges)

For more fine-grained control, you can specify an allow list of CIDR ranges that your Sandbox is permitted to connect to. All other outbound traffic will be blocked.
Important Notes:
  • Maximum of 10 CIDR entries per Sandbox
  • Supports both IPv4 and IPv6 addresses
  • Must use proper CIDR notation (e.g., "8.8.8.8/32" for a single IP, "10.0.0.0/8" for a range)
  • Cannot use allow_list and block_network together - they are mutually exclusive
  • Invalid CIDR values will trigger an error at creation time

Updating Network Permissions at Runtime

You can dynamically update the network permissions of a running Sandbox without restarting it. This allows you to change access policies during the sandbox’s lifetime.
Important Notes:
  • Cannot use block_network=True and allow_list together - they are mutually exclusive
  • Exposed ports remain accessible regardless of network restrictions
  • Changes take effect immediately without requiring a restart