Skip to content

localhost.localstack.cloud does not resolve in the sandbox, so the MCP server AWS client cannot reach LocalStack #1

Open

Description

@plafond

Summary

In a sandbox made from the kit, localhost.localstack.cloud does not resolve. Clients that use this name cannot reach the LocalStack in the sandbox. The largest effect is on the LocalStack MCP server: every call of its AWS client fails.

http://localhost:4566 works, so aws, lstk, and Terraform through lstk are not affected.

Environment

  • sbx 0.51.0, local sandbox, Linux (Arch, x86_64, KVM)
  • Kit docker.io/localstack/sbx-localstack-claude:0.1.0, empty workspace, no project lstk config
  • LocalStack image localstack/localstack-pro:latest, LocalStack MCP server 0.7.0

Not tested: macOS, Windows, other sbx versions.

What fails

Check Result
control: AWS CLI reaches LocalStack at localhost:4566 PASS
control: a public name resolves in the sandbox (github.com) PASS
getent hosts localhost.localstack.cloud in the sandbox FAIL
aws --endpoint-url http://localhost.localstack.cloud:4566 s3 ls (the smoke check "LocalStack hostnames reach the sandbox emulator") FAIL
getent hosts localhost.localstack.cloud in the LocalStack container FAIL
MCP localstack-aws-client with the command s3 ls FAIL: Could not connect to the endpoint URL

The start log of the kit shows the same problem:

> Note: Could not resolve localhost.localstack.cloud, falling back to 127.0.0.1.

Cause

The kit denies localhost.localstack.cloud and **.localhost.localstack.cloud in its network policy, so that a request through the sandbox proxy cannot reach a LocalStack on the host. sbx 0.51.0 also applies the deny rule to DNS, so the lookup is refused:

$ sbx policy check network --sandbox <name> localhost.localstack.cloud:4566
  Denied:      localhost.localstack.cloud:4566
  Reason:      denied by local rule rule "kit:<name>:deny"

$ sbx policy log <name>
<name> network localhost.localstack.cloud <dns proxy policy> DNS lookup blocked by proxy policy

The kit adds the names to NO_PROXY, but a client must resolve the name before it can connect directly. The kit docs name sbx 0.45, where the smoke check passed, so the DNS enforcement is probably newer than that.

The MCP server is affected because its AWS client runs awslocal in the LocalStack container. In the container, awslocal uses the endpoint http://localhost.localstack.cloud:4566, and the container uses the DNS of the sandbox.

Reproducer

Needs sbx (signed in) and LOCALSTACK_AUTH_TOKEN. Uses no model credits. Exit code 1 means the problem reproduces.

repro.sh
#!/usr/bin/env bash
# Reproducer: in a Docker Sandbox made from the LocalStack kit,
# localhost.localstack.cloud does not resolve, so clients that use this name
# (the AWS CLI with --endpoint-url, and the AWS client of the LocalStack MCP
# server) cannot reach the LocalStack in the sandbox.
#
# Usage: ./repro.sh [KIT]
#   KIT  kit set to test (default: docker.io/localstack/sbx-localstack-claude:0.1.0)
#   KEEP=1 keeps the sandbox after the run.
#
# Needs sbx (signed in with `sbx login`) and LOCALSTACK_AUTH_TOKEN. Uses no
# model credits.
set -uo pipefail

KIT="${1:-docker.io/localstack/sbx-localstack-claude:0.1.0}"
NAME="lskit-hostname-repro-$RANDOM"
HERE="$(cd "$(dirname "$0")" && pwd)"
WORKSPACE="$HERE/.work/workspace"
failed=0

in_sandbox() { sbx exec "$NAME" bash -c "$1"; }

check() {
  local description="$1"
  shift
  if "$@" >/dev/null 2>&1; then
    echo "PASS  $description"
  else
    echo "FAIL  $description"
    failed=$((failed + 1))
  fi
}

cleanup() {
  kill "${keepalive:-}" 2>/dev/null || true
  if [[ "${KEEP:-0}" == 1 ]]; then
    echo "==> kept $NAME"
  else
    sbx rm --force "$NAME" >/dev/null 2>&1 || true
  fi
}

mcp_aws_call() {
  in_sandbox '{
    echo "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-06-18\",\"capabilities\":{},\"clientInfo\":{\"name\":\"repro\",\"version\":\"0\"}}}"
    echo "{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\"}"
    echo "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"localstack-aws-client\",\"arguments\":{\"command\":\"s3 ls\"}}}"
    sleep 20
  } | timeout 40 lskit-mcp 2>/dev/null'
}

: "${LOCALSTACK_AUTH_TOKEN:?set LOCALSTACK_AUTH_TOKEN}"
mkdir -p "$WORKSPACE"
trap cleanup EXIT

echo "==> sbx: $(sbx version 2>&1 | head -n 1)"
echo "==> creating $NAME from $KIT"
sbx create --name "$NAME" -e LOCALSTACK_AUTH_TOKEN "$KIT" "$WORKSPACE" >/dev/null || exit 1
# sbx stops an idle sandbox 30 seconds after its last session.
sbx exec "$NAME" sleep 86400 >/dev/null 2>&1 &
keepalive=$!

echo "==> waiting for LocalStack"
for _ in $(seq 1 84); do
  state="$(in_sandbox lskit-status 2>/dev/null | tail -n 1)"
  [[ -n "$state" && "$state" != starting ]] && break
  sleep 5
done
echo "    lskit-status: ${state:-unknown}"
in_sandbox 'docker ps --format "    container: {{.Names}}  image: {{.Image}}"'

echo "==> checks"
check "control: AWS CLI reaches LocalStack at localhost:4566" \
  in_sandbox 'aws s3 mb s3://hostname-repro && aws s3 ls | grep -q hostname-repro'
check "control: a public name resolves in the sandbox (github.com)" \
  in_sandbox 'getent hosts github.com'
check "localhost.localstack.cloud resolves in the sandbox" \
  in_sandbox 'getent hosts localhost.localstack.cloud'
check "AWS CLI reaches LocalStack at localhost.localstack.cloud:4566" \
  in_sandbox 'aws --endpoint-url http://localhost.localstack.cloud:4566 s3 ls | grep -q hostname-repro'
check "localhost.localstack.cloud resolves in the LocalStack container" \
  in_sandbox 'docker exec "$(head -n 1 /tmp/localstack-kit/container-name)" getent hosts localhost.localstack.cloud'
mcp_output="$(mcp_aws_call)"
check "MCP server AWS client lists the bucket" grep -q hostname-repro <<<"$mcp_output"

echo "==> evidence"
echo "--- MCP AWS client answer (id 2)"
grep '"id":2' <<<"$mcp_output" | cut -c1-400
echo "--- lstk start log"
in_sandbox 'grep -i "resolve" /tmp/localstack-kit/start.log' || true
echo "--- sbx policy check"
sbx policy check network --sandbox "$NAME" localhost.localstack.cloud:4566 2>&1 | sed 's/^/    /'
echo "--- sbx policy log (DNS)"
sbx policy log "$NAME" 2>&1 | grep -i "localhost.localstack.cloud" | grep -i dns | head -n 4 | sed -E 's/ +/ /g; s/^/    /'

echo
if ((failed > 0)); then
  echo "$failed check(s) failed: the problem reproduces"
  exit 1
fi
echo "all checks passed: the problem does not reproduce"
Output with kit 0.1.0 and sbx 0.51.0
==> sbx: sbx version v0.51.0 7d55286de0c775148b985ed349f760f1eba06203
==> creating lskit-hostname-repro-24756 from docker.io/localstack/sbx-localstack-claude:0.1.0
==> waiting for LocalStack
    lskit-status: running
container: localstack-main  image: localstack/localstack-pro:latest
==> checks
PASS  control: AWS CLI reaches LocalStack at localhost:4566
PASS  control: a public name resolves in the sandbox (github.com)
FAIL  localhost.localstack.cloud resolves in the sandbox
FAIL  AWS CLI reaches LocalStack at localhost.localstack.cloud:4566
FAIL  localhost.localstack.cloud resolves in the LocalStack container
FAIL  MCP server AWS client lists the bucket
==> evidence
--- MCP AWS client answer (id 2)
{"result":{"content":[{"type":"text","text":"❌ **Command Failed**\n\n============================================================================\n  WARNING: 'awslocal' is deprecated. Use 'lstk aws' instead.\n============================================================================\n\n  'awslocal' no longer receives updates.\n\n  Get started with 'lstk', the new LocalStack CLI:\n  https://docs.
--- lstk start log
> Note: Could not resolve localhost.localstack.cloud, falling back to 127.0.0.1.
--- sbx policy check
      Denied:      localhost.localstack.cloud:4566
      Governance:  Local policy only
      Context:     sandbox:lskit-hostname-repro-24756
      Reason:      denied by local rule rule "kit:lskit-hostname-repro-24756:deny"
--- sbx policy log (DNS)
    lskit-hostname-repro-24756 network localhost.localstack.cloud.lskit-hostname-repro-24756.docker.internal network <dns proxy policy> DNS lookup blocked by proxy policy 17:32:56 13-Nov 16
    lskit-hostname-repro-24756 network localhost.localstack.cloud network <dns proxy policy> DNS lookup blocked by proxy policy 17:32:56 13-Nov 16
    lskit-hostname-repro-24756 network s3.localhost.localstack.cloud.lskit-hostname-repro-24756.docker.internal network <dns proxy policy> DNS lookup blocked by proxy policy 17:32:47 13-Nov 1
    lskit-hostname-repro-24756 network s3.localhost.localstack.cloud network <dns proxy policy> DNS lookup blocked by proxy policy 17:32:47 13-Nov 1

4 check(s) failed: the problem reproduces

Proposed fix

Keep the deny rules, and make the name resolve without DNS: write 127.0.0.1 localhost.localstack.cloud to /etc/hosts in the sandbox at each boot and in the LocalStack container after each start. A pull request follows.

A hosts file has no wildcards, so subdomains such as s3.localhost.localstack.cloud still do not resolve.

Activity

  1. plafond commented on Nov 15, 2026

    @plafond
    Author

    More detail on the cause, found while I reworked #2.

    The LocalStack container has its own DNS server that resolves localhost.localstack.cloud and its subdomains. In the sandbox this server does not start, because LocalStack finds no upstream DNS server. It looks for one with a lookup of localstack.cloud, and the sandbox resolver answers only names that a network rule allows. The LocalStack log shows:

    Unable to determine fallback DNS. Please check if 'localstack.cloud' is reachable by your configured DNS servers
    Error starting the DNS server: No upstream dns server found.
    

    With DNS_SERVER set to the sandbox resolver (the first nameserver in /etc/resolv.conf of the sandbox, 172.17.0.0 here), the server starts. The name and its subdomains then resolve in the LocalStack container and in Lambda containers, and other lookups still go through the sandbox resolver and its policy.

    The sandbox cannot use that server, because /etc/resolv.conf is a read-only mount there. So #2 now sets the DNS upstream for the container and keeps one /etc/hosts line for the sandbox.

    Environment: kit 0.1.0, localstack/localstack-pro:latest, sbx 0.51.0, Docker, local sandbox, Linux x86_64.

  2. plafond commented on Nov 16, 2026

    @plafond
    Author

    Update: the cause is in two kit network rules, and #2 now fixes it there with no script changes.

    • sbx 0.51.0 resolves a name only if a rule allows it, and it refuses the DNS lookup of a name that a deny rule lists. The kit denies the LocalStack names, so they do not resolve in the sandbox.
    • The kit does not allow localstack.cloud, which LocalStack looks up to find an upstream DNS server. So the LocalStack DNS server does not start, as my comment above describes.

    With the names allowed and localstack.cloud:443 allowed, the names and their subdomains resolve in the sandbox, in the LocalStack container, and in Lambda containers. The proxy still refuses the names, because sbx checks the resolved address against the kit's deny rule for 127.0.0.0/8. I tested that with a listener on the host, under the default policy and with an allow-all rule. The results are in #2.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions