# Why does my custom template fail with 'port 49999 not open'? (/docs/faq/port-49999-not-open)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 752 · updated: 2026-07-30 -->
Related: [How do I increase my concurrency limit?](/docs/faq/increase-concurrency.md), [Do paused sandboxes count toward the concurrency limit?](/docs/faq/paused-sandboxes-concurrency.md), [Is there a limit on how many templates I can create?](/docs/faq/template-limit.md), [Can I make a template public so other projects can use it?](/docs/faq/public-templates.md), [Can I run sandboxes in the EU?](/docs/faq/eu-region.md), [Why does iptables fail with 'xt_owner module missing' in a sandbox?](/docs/faq/iptables-xt-owner.md)

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**

```txt
{"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 [#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.

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```js  
      import { Template } from '@e2b/code-interpreter'

      const template = Template().fromTemplate("code-interpreter-v1")
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b_code_interpreter import Template

      template = Template().from_template("code-interpreter-v1")
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

<Note>
  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:
</Note>

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```ts  
      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")
          )
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b_code_interpreter import Template, wait_for_url

      template = (
          Template()
          .from_image("e2bdev/code-interpreter:latest")
          .set_start_cmd(
              "sudo /root/.jupyter/start-up.sh", wait_for_url("http://localhost:49999/health")
          )
      )
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>
