localhost.
Symptom
A sandbox that worked on Alpine may enter a crash loop after switching to an image such asnode:22-bookworm-slim. Its logs show an error like:
sandbox-api is running because the system cannot resolve localhost to a loopback address.
Root cause
Slim or minimal Debian distributions may omit the/etc/hosts entry or name service configuration in nsswitch.conf that resolves localhost.
When an application or a utility such as netcat (nc) connects to localhost, the system performs a name lookup. Without an explicit hosts mapping or suitable resolver configuration, that lookup fails with getaddrinfo before the request reaches the network stack.
Use the loopback IP
Replacelocalhost with 127.0.0.1 in entrypoint scripts, health checks, and tool server configurations. Using the explicit loopback address bypasses hostname resolution.
Configure clients to connect to 127.0.0.1. Configure servers to listen on 0.0.0.0 when they must also be reachable through external container ports.
Check a Debian migration
When moving from Alpine tobookworm-slim:
- Install
ca-certificatesexplicitly to prevent Git clone and HTTPS failures - Replace
localhostwith127.0.0.1in internal scripts - Verify that
EXPOSEinstructions and port mappings, such as port8081for an internal API, match your infrastructure
Sandbox proxy and network
Learn how networking works inside Blaxel sandboxes.
Sandbox ports
Configure ports exposed by sandbox services.