# Publish

Publish an HTTP or TCP service on port 8080 through Teleport.



Publishing exposes a running service through Teleport application access.

**Install the client tools and sign in**

Beams is a [Teleport](https://goteleport.com) project and uses [official Teleport client tools](https://goteleport.com/download/client-tools/).

The client tools include `tsh` to sign in and run commands, and `tctl` to administer your cluster if you have permission.



Cluster: `example.beams.run`. Edit this example to use your cluster name.

Install version **18.11.10** of the client:

**macOS**

Download and open the macOS installer, then follow its instructions.

```sh
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkg
```

**Linux**

For Linux x86-64, download and install the client tools:

```sh
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/install
```

**Windows**

For Windows x86-64, run these commands in PowerShell. Add the extraction directory (`$env:LOCALAPPDATA\Teleport`) to your user PATH to use `tsh` in future terminals; the last command adds it to this terminal's PATH.

```powershell
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"
```

Follow the official client [tools install guide](https://goteleport.com/download/client-tools/) for other versions and architectures.

Check that you’re running v18.11.10 of the client with `tsh version`.

```sh
tsh version
```

**Passwordless**

I sign in without a password (e.g. a passkey).

```sh
tsh login --proxy='example.beams.run' --auth=passwordless
```

**Password \& MFA**

I have a password & MFA set up for my account:

Replace `you@example.com` with your Teleport username.

```sh
tsh login --proxy='example.beams.run' --user=you@example.com
```

**SSO**

I sign in with SSO (e.g. Okta, GitHub, SAML).

```sh
tsh login --proxy='example.beams.run'
```

## Prepare a service

Only **port 8080** is currently supported. Configure your app to listen on that port and bind to an interface reachable from the beam, typically `0.0.0.0`.

To start an isolated example server:

**Inside the beam**

```sh
mkdir -p ~/preview
printf '<h1>Hello from a Beam</h1>\n' > ~/preview/index.html
python3 -m http.server 8080 --bind 0.0.0.0 --directory ~/preview
```

The Python server stays in the foreground. Leave that terminal open while publishing from another local terminal. For long-running work, use managed services rather than relying on an attached shell.

> Serve only files intended for the preview. Do not point a web server at your home directory, repository root, credentials, or internal data.

## Publish HTTP

Find the beam's generated name with `tsh beams ls`. Replace `my-beam` with that name in the commands below.

**Local terminal**

```sh
tsh beams publish my-beam
```

Teleport returns an authenticated HTTPS application URL. Use the returned URL rather than guessing it. Access is governed by Teleport permissions; this is not anonymous public hosting.

## Publish TCP

To try TCP publishing instead of HTTP publishing, use a beam that has not already been published as HTTP. The service still needs to listen on port 8080. You can use the Python server above: Teleport forwards TCP traffic, and the client and server still speak HTTP over that connection.

**Local terminal**

```sh
tsh beams publish --tcp my-beam
```

On your workstation, run `tsh apps ls` and find the published application's name. Replace `my-tcp-app` with that name (not its URL) and start a local proxy. Leave it running.

**Local terminal**

```sh
tsh proxy app --port=18080 my-tcp-app
```

In another terminal on the same workstation, request the example page through the local proxy. This check passes only if the request succeeds and returns the heading from the beam.

**Local terminal**

```sh
page=$(curl --fail --silent --show-error --max-time 10 http://127.0.0.1:18080/) &&
  printf '%s\n' "$page" | grep -Fx '<h1>Hello from a Beam</h1>'
```

Expect `<h1>Hello from a Beam</h1>` and a zero exit status. For a service that doesn't speak HTTP, use its native client against `127.0.0.1:18080` and verify an expected response. Stop the local proxy with Ctrl-C when you're done.

## Lifetime and cleanup

The application depends on the running beam and service. Publishing does not save your files or keep the runtime alive indefinitely. Stop the example server with Ctrl-C when finished. To remove the beam:

**Local terminal**

```sh
tsh beams rm my-beam
```

Save any required work through a [phase build beam](/docs/phases/getting-started/) before removing it.
