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).
Exposed sandbox URLs are public. Add authentication inside the application before exposing sensitive data or operations. Outbound network restrictions do not authenticate inbound requests. The application must listen on the exposed port on 0.0.0.0 or ::; creating a URL does not start a server.

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 and no runtime secrets, the sandbox cannot initiate outbound connections. With brokered secrets, only their approved credential hosts are reachable. Exposed ports remain accessible in either case.

Allow Lists

Allow only specific hostnames, wildcard domains, IPs, or CIDRs. Other destinations are blocked:
Allowlists accept up to 64 entries, including bare IPv4/IPv6 addresses and CIDRs. Bare IPs mean one host (/32 for IPv4, /128 for IPv6). Wildcards match subdomains, excluding the apex; hostname rules contain no scheme, port, or path. Hostname rules inspect TLS SNI on port 443 or HTTP Host on port 80 and resolve hosts on the worker. Other TCP ports and protocols need IP or CIDR rules. The proxy rejects private, loopback, and link-local destinations even with an explicit IP/CIDR rule; allowlists do not create private-network access. Under restricted policies, UDP/ICMP are blocked except DNS to the configured resolver. Do not combine an explicit allow_list with block_network=True. Credential host rules must fit within an explicit allowlist’s hostname rules; IP/CIDR entries alone do not cover them, and a secret does not widen the list. Without network restrictions, other public destinations remain reachable but only approved hosts receive substituted credentials. Worker-proxied connections use the worker’s source IP, including CIDR targets.

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.
Changes close existing connections and take effect without a restart. Inbound port exposure is independent of outbound restrictions.