Skip to content

.run_code breaks when Sandbox.allow_public_traffic is False #177

Closed

Description

@hewliyang
sandbox = Sandbox.create(network={"allow_public_traffic": False})
sandbox.run_code("print('hello world')")
---------------------------------------------------------------------------
SandboxException                          Traceback (most recent call last)
Cell In[3], line 1
----> 1 sandbox.run_code("print('hello world')")

File ~/Developer/brightriver-app/backend/.venv/lib/python3.11/site-packages/e2b_code_interpreter/code_interpreter_sync.py:210, in Sandbox.run_code(self, code, language, context, on_stdout, on_stderr, on_result, on_error, envs, timeout, request_timeout)
    208 err = extract_exception(response)
    209 if err:
--> 210     raise err
    212 execution = Execution()
    214 for line in response.iter_lines():

SandboxException: 403: {"sandboxId":"i7vvwx4sz8os1ddbw7rrj","message":"Sandbox is secured with traffic access token. Token header 'e2b-traffic-access-token' is missing","code":403}

same for .create_code_context or any other method that sends a request to the sandbox.

according to https://e2b.dev/docs/sandbox/internet-access#restricting-public-access-to-sandbox-urls
we need to pass in traffic_access_token as e2b-traffic-access-token.

Activity

  1. linear commented on Nov 25, 2025

    @linear
  2. self-assigned this
    on Nov 25, 2025
  3. mishushakov commented on Nov 26, 2025

    @mishushakov
    Member

    Hey, this is fixed now in

    e2b_code_interpreter==2.4.1

    Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions