Scenario
A published port that answered on one loopback
RolesAgent Systems EngineeringCustomer AI Deployment
- Engine
- sbx v0.47.0
- Model
- none; shell commands inside the sandbox
- Hardware
- one Mac with the microVM runtime
Situation
A developer serves a static site from inside a sandbox on port 8080 and publishes it to the host with sbx ports m101-demo --publish 18081:8080. A browser on the host opens the page. A test harness on the same host reports that it could not connect, and its log shows that it tried ::1. The developer suspects that the server inside the sandbox listens on one interface only and starts editing its configuration.
You have the publish command and its listing, the same URL fetched on both loopback addresses, the listing in sbx ls, a second publish with a protocol named, and the unpublish calls.
Questions
- Which side refused the connection, the server in the sandbox or the host binding? What in the listing says so?
- What does a publish without a protocol bind, and since which release?
- How do you publish so that both loopbacks answer?
- The -p flag on sbx run did not help on a re-attach. Why?
- How do you remove a binding, and how do you check that it is gone?
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
a port published without a protocol, and the listing
Read the protocol column.
$ sbx ports m101-demo --publish 18081:8080
Published 127.0.0.1:18081 -> 8080/tcp4
[exit 0]
$ sbx ports m101-demo
HOST IP HOST PORT SANDBOX PORT PROTOCOL
127.0.0.1 18081 8080 tcp4
[exit 0]Source: manuals/docker-sandboxes-101/capture/out/05-ports.txt
the same URL on the two loopback addresses
Read the status code and the exit code of each request.
$ curl -sS -o /dev/null -w '%{http_code}\n' http://127.0.0.1:18081/README.md
200
[exit 0]
$ curl -sS -o /dev/null -w '%{http_code}\n' 'http://[::1]:18081/README.md'
curl: (7) Failed to connect to ::1 port 18081 after <n> ms: Couldn't connect to server
000
[exit 7]Source: manuals/docker-sandboxes-101/capture/out/05-ports-curl.txt
the binding in the PORTS column of sbx ls
The column names the host address and the protocol.
$ sbx ls
SANDBOX AGENT STATUS PORTS WORKSPACE
m101-demo shell running 127.0.0.1:18081->8080/tcp4 $CAPTURE/fixtures/repo
[exit 0]Source: manuals/docker-sandboxes-101/capture/out/05-ports-ls.txt
a publish with the protocol named, and the JSON listing
Read the host_ip of each record.
$ sbx ports m101-demo --publish 8080/tcp
Published 127.0.0.1:<port> -> 8080/tcp
Published [::1]:<port> -> 8080/tcp
[exit 0]
$ sbx ports m101-demo --json
[
{
"host_ip": "127.0.0.1",
"host_port": 18081,
"sandbox_port": 8080,
"protocol": "tcp4"
},
{
"host_ip": "127.0.0.1",
"host_port": "<port>",
"sandbox_port": 8080,
"protocol": "tcp"
},
{
"host_ip": "::1",
"host_port": "<port>",
"sandbox_port": 8080,
"protocol": "tcp"
}
]
[exit 0]Source: manuals/docker-sandboxes-101/capture/out/05-ports-tcp.txt
two unpublish calls and the empty listing
The spec of each unpublish matches the spec that published it.
$ sbx ports m101-demo --unpublish 18081:8080
Unpublish requested for port 18081 -> 8080
[exit 0]
$ sbx ports m101-demo --unpublish <port>:8080/tcp
Unpublish requested for port <port> -> 8080/tcp
[exit 0]
$ sbx ports m101-demo --json
[]
[exit 0]Source: manuals/docker-sandboxes-101/capture/out/05-ports-unpublish.txt
The answer
Show the walkthrough
- Read the protocol column. The publish answered
Published 127.0.0.1:18081 -> 8080/tcp4, and the listing shows one row with the host address127.0.0.1and the protocoltcp4. The host binding is IPv4 only. The server inside was never asked. - Confirm with the two fetches.
127.0.0.1:18081returns 200.[::1]:18081fails to connect and curl exits 7. The failing side is the host loopback where nothing listens. - Name the rule. Without a protocol, publishing uses
tcp4, so the host side is127.0.0.1alone. The manual dates the change to v0.42.0: a published port no longer listens on::1unless you name the protocol. The 2025 plugin bound both loopbacks, which conflict C39 records.sbx lsshows the same binding in itsPORTScolumn. - Publish for both families.
--publish 8080/tcpbinds127.0.0.1and[::1]on ephemeral host ports, andsbx ports --jsonlists three records: the firsttcp4binding and twotcpones, one per address. Name a host port in the spec when the harness needs a fixed one. - Remove what you no longer need.
--unpublish 18081:8080and--unpublish <port>:8080/tcpeach remove their mapping, and the JSON listing ends empty.-ponsbx runapplies at creation only, so later changes go throughsbx ports.
Show the resolution
The server was fine. The host binding was tcp4, so only 127.0.0.1 listened, and the harness's connection to ::1 found no listener. Publishing 8080/tcp with a fixed host port gives both loopbacks a binding, and the harness connects. The edits inside the sandbox are reverted.
Show the wrong turns
“Bind the server inside the sandbox to all interfaces.”
The guest side already answered through the IPv4 mapping. The missing listener was on the host loopback.
“Pass -p 18081:8080/tcp on the next sbx run.”
On an existing sandbox the flag is ignored. Use sbx ports.
“Turn off IPv6 in the test harness.”
It works, and it hides a binding rule that the next harness will hit again.
Show the general rule
When one client reaches a service and another does not, compare the addresses each one used before you touch the service. A port mapping has its own address family, and a listing that prints it saves an hour of edits in the wrong place.
Taught in
The ports page gives the tcp4 rule and the protocol table, and the conflicts register records the change as C39.