# Ports

Forward a port from an AI Team Cloud Computer to localhost on this computer, open it in your browser, and forward the ports a session starts.



## Forward a port [#forward-a-port]

<Steps>
  <Step title="Start the server on the AI Team Cloud Computer">
    In a session, start whatever listens on the port, for example a dev server on port 3000. It must
    use a port from 1024 to 65535.
  </Step>

  <Step title="Forward it">
    Press **+** in the HQ sidebar's **Ports** view, or right-click a team and choose
    **Forward a Port...**. Type the AI Team Cloud Computer's port, then the port on this computer (leave it as
    it is to use the same number).
  </Step>

  <Step title="Use it">
    The Ports view lists the forward as `3000 → localhost:3000`, with the team's name (and, with more
    than one HQ account signed in, the account, as in `Backend team · owner@client`). Its buttons
    open it in your browser (**Open in Browser**), copy `http://localhost:3000`
    (**Copy Local Address**), and stop it (**Stop Forwarding**).
  </Step>
</Steps>

You need editor or owner access to the team and an active plan. Starting a forward wakes an AI Team
Cloud Computer that is off. The status bar counts your active forwards; click the count to open the Ports
view.

## Ports a session starts [#ports-a-session-starts]

While one of a team's sessions is open in a terminal, the Ports view lists the ports its Cloud Computer
starts listening on, as `8000 detected · Forward?`. Press **Forward** to forward it to the same
port on this computer, or **Dismiss** to hide it.

## After a reload [#after-a-reload]

Forwards that were running when you closed the window come back **paused**
(`paused · click to resume`). Click one to start it again. They never start, or wake a Cloud Computer, on
their own. A forward that HQ ended is paused too, and the extension says
"The forward of port 3000 ended."

A window brings back the paused forwards of the account it uses. Paused forwards are kept per
account, and if two windows had forwards open on the same account, the ones that come back are
those of the last window that had any open.

## Good to know [#good-to-know]

* A forwarded port listens on `127.0.0.1` only, so other computers on your network cannot reach
  it. Any program on this computer can, while the forward is open.
* On the AI Team Cloud Computer, a forward reaches whatever listens on that port, including another
  member's dev server.
* HQ refuses some ports: the Docker API (2375 and 2376), the Node debugger (9229 and 9230), and
  ports the AI Team Cloud Computer uses itself. The extension says "Port 2375 cannot be forwarded: the AI Team
  Cloud Computer uses it itself."
* A forward works as the account that started it, whichever account the window uses now. Signing
  out of that account stops it, in every window; other accounts' forwards keep running.
* If another window renews the forward's account, the forward restarts on the same local port.
* A port offered from a session terminal forwards as that terminal's account.
* If Developer access was turned on after the team's Cloud Computer started, forwarding waits for one
  restart. The team's **Settings** in HQ say "Restart needed so port forwarding works", and an
  organization owner or admin presses **Restart Cloud Computer** there. Sessions pause for about two
  minutes and come back where they were.

## Related [#related]

<Cards>
  <Card title="Terminals" href="/docs/vscode/terminals/">
    Start a server from a session terminal.
  </Card>

  <Card title="Troubleshooting" href="/docs/vscode/troubleshooting/">
    Refused and ended forwards.
  </Card>
</Cards>
