Error: "The sandbox is running but port is not open" on port 49999 when using specific template
Describe the bug: I am encountering an error message The sandbox is running but port is not open when trying to use an E2B sandbox created from a specific template. The sandbox instance itself seems to start successfully, but the specified port 49999 is reported as not accessible from the outside.
Sandbox Details:
- Sandbox ID: iojbyrxp6ik2vhga55m7j
- Port Expected: 49999
Problem Context: I have investigated this issue and have isolated the cause to the specific E2B template I am using. When using other templates or basic configurations, port forwarding generally works as expected. This leads me to believe the issue lies within the template's definition, startup script, or the application environment it sets up.
can you share the template?
@rookiefzk0903 This was not obvious to me, but make sure you do e2b template build -c "/root/.jupyter/start-up.sh" (with the -c argument passed) when building the template.
I'm seeing this issue as well, here is my agent
You can use most Debian-based base images
FROM e2bdev/code-interpreter:latest
# Install dependencies and customize sandbox
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential
# Install Node.js (required for Codex CLI)
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs
# Install OpenAI Codex CLI
RUN npm install -g @openai/codex
# Set working directory
WORKDIR /workspace
CMD ["sleep", "infinity"]
Hey! If you're building a template based on
FROM e2bdev/code-interpreter:latest
You should be building it with a start command:
e2b template build -c "/root/.jupyter/start-up.sh"
Otherwise, the server will not start and you won't be able to run code.
Hey! If you're building a template based on
FROM e2bdev/code-interpreter:latest You should be building it with a start command:
e2b template build -c "/root/.jupyter/start-up.sh"Otherwise, the server will not start and you won't be able to run code.
This still happens,
FROM python:3.11.6
# Inspired by https://github.com/nodejs/docker-node/blob/main/20/bookworm/Dockerfile
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \
build-essential curl git util-linux \
libbluetooth-dev tk-dev uuid-dev \
gh; \
rm -rf /var/lib/apt/lists/*
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
ENV NODE_VERSION 22.1.0
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
&& export GNUPGHOME="$(mktemp -d)" \
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& set -ex \
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
141F07595B7B3FFE74309A937405533BE57C7D57 \
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \
61FC681DFB92A079F1685E77973F295594EC4689 \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
108F52B48DB57BB0CC439B2997B01419BD92F80A \
A363A499291CBBC940DD62E41F10027AF002F8B0 \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
# smoke tests
&& node --version \
&& npm --version
ENV YARN_VERSION 1.22.19
RUN set -ex \
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& mkdir -p /opt \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
# smoke test
&& yarn --version
RUN npm install -g @openai/codex
Running with e2b template build -c "/root/.jupyter/start-up.sh
@homanp as expected, there is no code interpreter in the image if it's based on python:3.11.6. In your case I am actually wondering if you need the code interpreter at all, maybe using the core E2B SDK should suffice?
@homanp as expected, there is no code interpreter in the image if it's based on
python:3.11.6. In your case I am actually wondering if you need the code interpreter at all, maybe using the core E2B SDK should suffice?
I'm trying to run OpenAI codes which requires Node > 22.1.
How can I achieve this?
Hi, we're running into the same issue and we really don't understand how to fix it. We followed the documentation. We don't have Python support, we use bash. We omitted the CMD/ENTRYPOINT. The image was pushed successfully, but when creating a sandbox, we see:
TimeoutError: {"sandboxId":"imrg8gvk4d2c7gw2o8tm2","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 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.
@StarpTech it looks like you're using CodeInterpreter but didn't build the sandbox with the start command.
Can you share your e2b.Dockerfile and e2b.toml?