Skip to content

Local Sandbox startup fails: proxy-everything exits with 'setsockoptint: protocol not available' and Sandbox DO loops on 'No such container' #522

@levi

Description

@levi

Summary

Local Sandbox startup fails on a minimal repro. The worker image builds successfully, but the request never reaches sandbox.exec(...) because the local proxy sidecar exits immediately and the Sandbox DO keeps retrying with:

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

The matching Docker proxy container exits with:

Fatal error:  setsockoptint: protocol not available

Minimal repro

Gist: https://gist.github.com/levi/186e349098b047bd95ceb8f9fac8328f

Key files:

  • package.json
  • wrangler.jsonc
  • src/index.ts
  • Dockerfile

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

Steps to reproduce

  1. bun install
  2. bun run dev
  3. In another terminal, curl -i http://localhost:8787/run

Expected behavior

GET /run should start the sandbox and return a JSON response containing:

hello from sandbox

Actual behavior

Wrangler starts successfully and reports the container image is ready. On the first request:

Uncaught Error: Network connection lost.
Monitoring container failed with: 404 {"message":"No such container: workerd-cf-sandbox-minimal-Sandbox-..."}
Container not ready, retrying

Docker shows the proxy sidecar for the sandbox exits immediately:

$ docker ps -a --format '{{.Names}}\t{{.Image}}\t{{.Status}}' | rg 'cf-sandbox-minimal|proxy-everything'
workerd-cf-sandbox-minimal-Sandbox-82533a8f52203aacd7ef6c91eb3b563c2d705983acae9f18f6de6658a4ce18ac-proxy  cloudflare/proxy-everything:3cb1195  Exited (1)
$ docker logs workerd-cf-sandbox-minimal-Sandbox-82533a8f52203aacd7ef6c91eb3b563c2d705983acae9f18f6de6658a4ce18ac-proxy
Fatal error:  setsockoptint: protocol not available

The docker inspect for that proxy container shows it is launched with CapAdd: ["NET_ADMIN"].

Repro source

src/index.ts

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 };

wrangler.jsonc

{
  "$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"
      ]
    }
  ]
}

Dockerfile

FROM docker.io/cloudflare/sandbox:0.7.20

WORKDIR /workspace

Notes

  • This reproduces outside my application code.
  • I also reproduced the same failure in a larger app using both WebSocket and HTTP transport modes locally; the minimal repro above does not depend on any custom application setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions