> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ports

Every TCP port a process in a sandbox listens on has its own public URL for HTTP and WebSocket traffic.

```text theme={null}
https://<sandbox_id>-<port>.<region>.sandbox.telnyxcompute.com
```

No port is declared in advance. A server that starts listening on port `3000` in sandbox `sb-us-east-1-0193c4d2-7f1a-7c2e-9d4b-5a6e8f0c1b2d` is reachable at once on `https://sb-us-east-1-0193c4d2-7f1a-7c2e-9d4b-5a6e8f0c1b2d-3000.us-east-1.sandbox.telnyxcompute.com`.

## Requests

* **Protocols.** HTTP and WebSocket. TLS ends at the platform, and the server in the sandbox receives plain HTTP/1.1. A client may negotiate HTTP/2 with the platform, and the sandbox still receives HTTP/1.1.
* **Path and body.** The path, query, and body reach the server unchanged.
* **Headers.** The platform adds `X-Forwarded-For`, `X-Forwarded-Host`, `X-Forwarded-Port`, `X-Forwarded-Proto`, `X-Real-Ip`, and `X-Request-Id`, and sends each request with `Connection: close`. The other headers reach the server as sent, apart from the traffic token.
* **Host.** The server receives the public host name in the `Host` header, so absolute links, redirects, and cookies work at the root path.
* **Origin.** Each port is its own browser origin.

Port `49983` is reserved for the platform and refused with `403 port_refused`.

## Access

`network.public_traffic` on the create controls access to every port of the sandbox. It is fixed at create.

| `public_traffic` | Access |
| - | - |
| `true` (default) | Anyone with the URL reaches the port. The sandbox ID is the only secret in the URL. |
| `false` | A request must carry the sandbox's `traffic_token` in the `Telnyx-Sandbox-Traffic-Token` header. A request without it receives `403 traffic_token_required`. |

The sandbox object returns `traffic_token` when `public_traffic` is `false`. The platform removes the header before the request reaches the sandbox. A fork receives its own traffic token.

```bash Shell theme={null}
curl https://$SANDBOX_ID-3000.us-east-1.sandbox.telnyxcompute.com/health \
  -H "Telnyx-Sandbox-Traffic-Token: $TRAFFIC_TOKEN"
```

## States

A port answers only while its sandbox is `running`.

| Condition | Response |
| - | - |
| The sandbox is `starting`, `paused`, or `terminated` | `502 sandbox_not_running` |
| Nothing listens on the port | `502 port_closed` |
| The sandbox does not answer the connection to the port | `502 port_unreachable` |
| More than 256 connections are open to the sandbox, across all its ports | `503 too_many_connections` |

Every refused request carries the error's title in a `Telnyx-Sandbox-Error` response header. See [Errors](https://developers.telnyx.com/docs/edge-compute/sandboxes/platform/errors.md#port-errors).

Traffic does not resume a paused sandbox. Send `connect` or `resume` first. See [Common Control Plane](https://developers.telnyx.com/docs/edge-compute/sandboxes/common-control-plane/user-controlled-lifecycle.md#pause-and-resume).

## Cookies

`telnyxcompute.com` is shared by every sandbox and every Edge Compute function. A cookie that a page in one sandbox sets for a parent domain reaches every other sandbox and function under that domain. A cookie set without a `Domain` attribute stays on its port's host name.
