Skip to main content

Documentation Index

Fetch the complete documentation index at: https://e2b.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

If you call .runCode / .run_code from the E2B Code Interpreter SDK against a custom template and see this error, the Code Interpreter service inside the sandbox didn’t start. This usually happens because the template was built without the Code Interpreter base image, or because the start command was not set. Example error
{"sandboxId":"ilmqag7sxz49zjc3gex7x","message":"The sandbox is running but port is not open","port":49999,"code":502}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeout' when starting the sandbox or calling '.set_timeout' on the sandbox with the desired timeout.

Solution

The simplest fix is to base your template on the official code-interpreter-v1 template, which already includes the start command and the Code Interpreter service.
import { Template } from '@e2b/code-interpreter'

const template = Template().fromTemplate("code-interpreter-v1")
We strongly recommend the approach above. If you need to build from the Docker image directly instead, you must also set the start command yourself:
import { Template, waitForURL } from '@e2b/code-interpreter'

const template = Template()
    .fromImage("e2bdev/code-interpreter:latest")
    .setStartCmd(
        "sudo /root/.jupyter/start-up.sh", waitForURL("http://localhost:49999/health")
    )