You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sandbox/internet-access.mdx
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,6 +229,55 @@ sandbox = Sandbox.create(
229
229
```
230
230
</CodeGroup>
231
231
232
+
### Updating network settings on a running sandbox
233
+
234
+
You can update the network configuration of an already running sandbox using `updateNetwork` (JavaScript) or `update_network` (Python). This replaces the current egress rules with the provided configuration without restarting the sandbox.
235
+
236
+
<CodeGroup>
237
+
```js JavaScript & TypeScript
238
+
import { Sandbox, ALL_TRAFFIC } from'e2b'
239
+
240
+
constsandbox=awaitSandbox.create()
241
+
242
+
// Tighten egress on the running sandbox: block 8.8.8.8
243
+
awaitsandbox.updateNetwork({
244
+
denyOut: ['8.8.8.8'],
245
+
})
246
+
247
+
// Replace with an allow-list only
248
+
awaitsandbox.updateNetwork({
249
+
denyOut: [ALL_TRAFFIC],
250
+
allowOut: ['api.example.com'],
251
+
})
252
+
253
+
// Toggle internet access without recreating the sandbox
`updateNetwork` / `update_network`**replaces** the current egress configuration — it does not merge with the existing rules. Calling it with an empty object (`updateNetwork({})` / `update_network({})`) clears all `allowOut` / `denyOut` / per-host rules set at create time.
277
+
</Note>
278
+
279
+
The create-only options `allowPublicTraffic` and `maskRequestHost` cannot be changed after the sandbox is created.
280
+
232
281
## Sandbox public URL
233
282
Every sandbox has a public URL that can be used to access running services inside the sandbox.
0 commit comments