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

# Publish ports from a sandboxed computer

> Expose a web server, API, notebook, or preview app running inside a Celesto computer through a public HTTPS URL with the SDK or CLI.

Services inside a Celesto computer are private by default. This isolation is useful for running agents, notebooks, APIs, and preview apps safely, but it also means you need to expose a service before you can open it in a browser or send a webhook to it.

Port publishing creates a public HTTPS URL that forwards traffic to a port inside the computer, so you can preview, test, and share running services without deploying them elsewhere.

A port is the numbered address a service listens on. For example, a local development server might listen on port `8000`.

## When to publish a port

Publish a port when you need to:

* Preview an app generated by an agent.
* Share a local API running inside a computer.
* Receive webhooks during a test run.
* Inspect a notebook, dashboard, or development server.

## Publish a service

The following example starts a simple HTTP server on port `8000`, publishes the port, prints the public URL, lists published ports, and then removes the published port.

<Steps>
  <Step title="Start a service and publish its port">
    Start a server inside the computer, publish the port, and open the returned HTTPS URL in your browser.

    <CodeGroup>
      ```python Python theme={null}
      from celesto import Computer


      computer = Computer(template_id="coding-agent")
      computer.run("python3 -m http.server 8000 &")

      url = computer.publish_port(8000)
      print(url)

      published_ports = computer.list_published_ports()
      print(published_ports)

      computer.unpublish_port(8000)
      computer.delete()
      ```

      ```ts TypeScript theme={null}
      import { Computer } from "@celestoai/sdk";

      const computer = await Computer.create({ templateId: "coding-agent" });
      await computer.run("python3 -m http.server 8000 &");

      const url = await computer.publishPort(8000);
      console.log(url);

      const publishedPorts = await computer.listPublishedPorts();
      console.log(publishedPorts);

      await computer.unpublishPort(8000);
      await computer.delete();
      ```

      ```bash CLI theme={null}
      celesto computer create --template coding-agent
      celesto computer run einstein "python3 -m http.server 8000 &"
      celesto computer port publish einstein
      celesto computer port list einstein
      celesto computer port unpublish einstein
      celesto computer delete einstein
      ```
    </CodeGroup>

    <Check>
      The publish command returns a public HTTPS URL that forwards traffic to the service running inside the computer.
    </Check>
  </Step>
</Steps>

## Inspect published ports

Use the list command when you need to confirm which ports are currently exposed for a computer.

```bash CLI theme={null}
celesto computer port list einstein
```

Each published port includes the internal port, the public URL, and its current status.

## Published port fields

<ResponseField name="port" type="integer">
  Port inside the computer that receives forwarded traffic.
</ResponseField>

<ResponseField name="url" type="string">
  Public HTTPS URL for the published service.
</ResponseField>

<ResponseField name="status" type="string">
  Current published-port state.
</ResponseField>

## Clean up published ports

Published URLs are intended for short-lived development and testing workflows. Remove a published port when you no longer need external access to the service.

```bash CLI theme={null}
celesto computer port unpublish einstein
```

<Tip>
  For short-lived previews, unpublish the port before deleting the computer.
</Tip>

## Troubleshooting

If the published URL does not load, check that the service is still running inside the computer and listening on the expected port.

```bash CLI theme={null}
celesto computer run einstein "curl -I http://localhost:8000"
```

If the command fails, restart the service and publish the port again.

<Note>
  Treat published URLs as public. If the service exposes sensitive data or actions, add authentication to the service before sharing the URL.
</Note>
