Skip to content

Instantly share code, notes, and snippets.

@levi
Created March 26, 2026 01:29
Show Gist options
  • Select an option

  • Save levi/186e349098b047bd95ceb8f9fac8328f to your computer and use it in GitHub Desktop.

Select an option

Save levi/186e349098b047bd95ceb8f9fac8328f to your computer and use it in GitHub Desktop.
Minimal repro for Cloudflare Sandbox local startup failure (proxy-everything exits with setsockoptint: protocol not available)

Cloudflare Sandbox local-dev repro

This is a minimal repro for local Cloudflare Sandbox startup failure.

Environment

  • macOS 15.3.0 (Darwin 25.3.0, arm64)
  • Bun 1.3.11
  • Node v20.20.1
  • Wrangler 4.77.0
  • Docker 28.5.2
  • Docker context: orbstack

Install

bun install

Run

bun run dev

In another terminal:

curl -i http://localhost:8787/run

Expected

The worker should start a sandbox container and return JSON with the output of:

echo hello from sandbox

Actual

The request hangs while the Sandbox DO retries container readiness. Wrangler logs show:

Monitoring container failed with: 404 {"message":"No such container: workerd-cf-sandbox-minimal-Sandbox-..."}

Docker shows the proxy sidecar exits immediately:

docker logs workerd-cf-sandbox-minimal-Sandbox-...-proxy
Fatal error:  setsockoptint: protocol not available
FROM docker.io/cloudflare/sandbox:0.7.20
WORKDIR /workspace
import {
getSandbox,
type Sandbox as SandboxType,
proxyToSandbox,
Sandbox,
} from "@cloudflare/sandbox";
type Env = {
Sandbox: DurableObjectNamespace<SandboxType>;
};
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const proxyResponse = await proxyToSandbox(request, env);
if (proxyResponse) {
return proxyResponse;
}
const url = new URL(request.url);
if (url.pathname === "/run") {
const sandbox = getSandbox(env.Sandbox, "minimal-test");
await sandbox.setEnvVars({
NODE_ENV: "production",
});
const result = await sandbox.exec("echo hello from sandbox");
return Response.json({
success: result.success,
stdout: result.stdout,
stderr: result.stderr,
exitCode: result.exitCode,
});
}
return new Response("Try GET /run");
},
} satisfies ExportedHandler<Env>;
export { Sandbox };
{
"name": "cf-sandbox-minimal",
"private": true,
"type": "module",
"scripts": {
"dev": "wrangler dev --port 8787",
"cf-typegen": "wrangler types"
},
"dependencies": {
"@cloudflare/sandbox": "0.7.20"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20260301.0",
"wrangler": "^4.77.0"
}
}
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "cf-sandbox-minimal",
"main": "src/index.ts",
"compatibility_date": "2026-03-17",
"compatibility_flags": [
"nodejs_compat",
"nodejs_compat_populate_process_env"
],
"containers": [
{
"class_name": "Sandbox",
"image": "./Dockerfile"
}
],
"durable_objects": {
"bindings": [
{
"name": "Sandbox",
"class_name": "Sandbox"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": [
"Sandbox"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment