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 theexpose_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.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.- 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_listandblock_networktogether - 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.- Cannot use
block_network=Trueandallow_listtogether - they are mutually exclusive - Exposed ports remain accessible regardless of network restrictions
- Changes take effect immediately without requiring a restart