Skip to content

docs(agents): explain Docker webhook networking (0.0.0.0 bind + loopback rewrite)#4721

Open
andresberrios wants to merge 1 commit into
electric-sql:mainfrom
andresberrios:docs/agents-webhook-host-networking
Open

docs(agents): explain Docker webhook networking (0.0.0.0 bind + loopback rewrite)#4721
andresberrios wants to merge 1 commit into
electric-sql:mainfrom
andresberrios:docs/agents-webhook-host-networking

Conversation

@andresberrios

Copy link
Copy Markdown

Problem

Following the agents docs on a local Docker setup, a custom app can spawn agents but they never respond, with no error surfaced anywhere — an unusually hard failure to diagnose that can push people off the platform. The runtime server runs in a Docker container (started by the CLI) while the app runs on the host, so webhook callbacks cross the Docker host boundary. Two behaviors are load-bearing here, and neither is documented:

  1. The app must listen on all interfaces (0.0.0.0), not just loopback. An app bound only to 127.0.0.1/localhost is unreachable from the container. Node's http server and @hono/node-server bind all interfaces by default, so the walkthrough's own example works — which quietly masks the requirement. Frameworks that default to loopback-only (e.g. Nuxt/Nitro) fail silently: the agent spawns, the webhook is never delivered, nothing is logged.

  2. Loopback serveEndpoint URLs are rewritten to host.docker.internal. rewriteLoopbackWebhookUrl (packages/agents-server/src/utils/webhook-url.ts) rewrites a serveEndpoint host of localhost/127.0.0.1/::1 to the Docker host before dispatching webhooks, gated by ELECTRIC_AGENTS_REWRITE_LOOPBACK_WEBHOOKS_TO (set to host.docker.internal by the CLI's docker-compose). This is why electric-ax agents types prints http://host.docker.internal:3000/electric-agents for a serveEndpoint configured as http://localhost:3000/... — currently unexplained, so readers can't tell how a container reaches a localhost URL, and can't reason about running the server on the host (where the variable is unset and the rewrite correctly does not apply).

Change

Docs only. Adds a ::: warning callout to:

  • app-setup.md (the runtime-handler reference) — after the HTTP server section.
  • walkthrough.md — right before the agents types output, so it explains the host.docker.internal line the reader is about to see.

Each callout covers the 0.0.0.0 bind requirement (and its silent-failure mode), the loopback rewrite and the env var that controls it, and the on-host caveat. No code or behavior changes.

…ack rewrite)

The runtime server runs in Docker while the app runs on the host, so
webhook callbacks cross the Docker host boundary. Two behaviors are
load-bearing but undocumented, and both fail silently:

- The app must listen on all interfaces (0.0.0.0). An app bound to
  loopback only (the default for some frameworks, e.g. Nuxt/Nitro) is
  unreachable from the container: the agent spawns but never responds,
  with no error surfaced. The walkthrough's @hono/node-server example
  happens to bind all interfaces, masking the requirement.
- A serveEndpoint host of localhost/127.0.0.1/::1 is rewritten to
  host.docker.internal before webhook dispatch (via
  ELECTRIC_AGENTS_REWRITE_LOOPBACK_WEBHOOKS_TO, set by the CLI compose).
  This is why `agents types` shows host.docker.internal for a localhost
  serveEndpoint — previously unexplained and confusing.

Add a warning callout to the app-setup reference and the walkthrough,
covering the 0.0.0.0 requirement, the loopback rewrite, and the
on-host caveat (variable unset when not running in Docker).
@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 6a05565
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/6a57bd54369e0e0008c49d6a
😎 Deploy Preview https://deploy-preview-4721--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant