Skip to main content
By default a sandbox can reach the whole internet. Set the rules on create with allow_internet_access and network, and replace them later on a running sandbox. The rules are enforced outside the sandbox, so nothing inside it can change them.

Rules on create

A bare address means that one address. A host name needs at least two labels (api.example.com). Any other field, or a misspelled network field, answers 400 that names it, so a rule is never dropped in silence.

How the rules combine

  • The more specific rule wins, and an allow wins a tie. denyOut: ["10.1.0.0/16"] with allowOut: ["10.0.0.0/8"] keeps 10.1.0.0/16 closed and the rest of 10.0.0.0/8 open. The same entry in both lists is allowed.
  • Allowlist. denyOut: ["0.0.0.0/0"] with allowOut host names reaches those hosts and nothing else over IPv4, and the sandbox can still resolve names. IPv6 stays open when only 0.0.0.0/0 is denied; add ::/0 to close it too. allow_internet_access: false with allowOut gives the same allowlist and closes IPv6 as well.
  • With internet on (the default), the sandbox reaches everything that denyOut does not close.
  • With internet off, the sandbox reaches only what allowOut lists.
  • Host names stand for the addresses they resolve to. The node resolves each name through its own resolver and renews the addresses when the answer’s time to live runs out, so a name that moves to a new address follows. Another name that shares one of those addresses is reachable too. With internet off, the sandbox reaches a resolver only when allowOut lists a host name, so a sandbox with no names has no DNS.
  • Mail ports (25, 465, 587), common mining ports, the node’s own management addresses and the addresses of other sandboxes are closed for every sandbox, whatever the rules say.

Create a sandbox with rules

With the E2B SDK (switch from E2B) the same rules are arguments of create:

Change the rules of a running sandbox

The answer is 204. The call replaces allowOut, denyOut and allowInternetAccess together: a field you leave out goes back to its default (nothing listed, internet on). The lists may sit at the top of the body or inside a network object as on create; when both are given they must be the same list. Other fields, such as dnsServers, answer 400. The new rules apply to the running sandbox at once. A sandbox that is paused deeply must be resumed first (see pause tiers).