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

# port-forward

> cpln port-forward — Establish secure local port forwarding to a running workload.

Establish secure local access to your workload.

Refer to the [cpln port-forward](/guides/cli/cpln-port-forward) guide for additional details.

**Usage**

```none theme={null}
cpln port-forward <ref> <ports...> [OPTIONS]
```

<Accordion title="Reference">
  ```text theme={null}
  Positionals:
    ref    The name of the workload to forward traffic to.  [string] [required]
    ports  Port mappings in the format [LOCAL_PORT:]REMOTE_PORT (e.g. 8080:80).  [array] [required] [default: []]

  Command options:
    --location  A global virtual cloud location  [string]
    --address   Addresses to listen on (comma separated). Only accepts IP addresses or localhost as a value. When localhost is supplied, cpln will try to bind on both 127.0.0.1 and ::1 and will fail if neither of these addresses are available to bind.  [default: "localhost"]
    --replica   The name of the workload deployment replica

  Context options:
    --profile  Override the profile. The default profile can be set using the `cpln profile set-default` command or by setting the CPLN_PROFILE environment variable
    --org      Override the organization. The default organization can be set in your profile by using the `cpln profile update` command
    --gvc      Override the global virtual cloud. The default global virtual cloud can be set in your profile by using the `cpln profile update` command

  Format options:
    --output, -o  Set the output format  [choices: "text", "json", "yaml", "json-slim", "yaml-slim", "tf", "crd", "names"]
    --color       Colorize the output  [boolean] [default: true]
    --ts          Timestamp format if the output format is text (e.g., --output=text)  [choices: "iso", "local", "age"]
    --max         Maximum number of records to show. A value less than 1 will return all records.  [number] [default: 50]

  Request options:
    --token         Override the authorization token
    --endpoint      Override the API URL
    --insecure, -k  Ignore TLS errors  [boolean]

  Debug options:
    --verbose, -v  Enable verbose output to stderr  [boolean] [default: false]
    --debug, -d    Show all HTTP communications  [boolean] [default: false]

  Options:
    --help     Show help  [boolean]
    --version  Show version number  [boolean]
  ```

  [Common Options Reference](/cli-reference/using-cli/common-options)
</Accordion>

<Accordion title="Example">
  * Forward a single port from workload to local machine

  <CodeGroup>
    ```bash Command theme={null}
    cpln port-forward db-workload 5432:5432 --location aws-us-west-1 --org demo-org --gvc demo-gvc
    ```

    ```text Output theme={null}
    Forwarding from 127.0.0.1:5432 -> 5432
    ```
  </CodeGroup>

  * Forward multiple ports from workload to local machine

  <CodeGroup>
    ```bash Command theme={null}
    cpln port-forward db-workload 8080:80 8443:443 --location aws-us-west-1 --org demo-org --gvc demo-gvc
    ```

    ```text Output theme={null}
    Forwarding from 127.0.0.1:8080 -> 80
    Forwarding from 127.0.0.1:8443 -> 443
    ```
  </CodeGroup>

  * Forward workload ports to multiple addresses

  <CodeGroup>
    ```bash Command theme={null}
    cpln port-forward db-workload 5432:5432 --address 0.0.0.0,127.0.0.1 --location aws-us-west-1 --org demo-org --gvc demo-gvc
    ```

    ```text Output theme={null}
    Forwarding from 0.0.0.0:5432 -> 5432
    Forwarding from 127.0.0.1:5432 -> 5432
    ```
  </CodeGroup>

  * Assign an ephemeral local port

  <CodeGroup>
    ```bash Command theme={null}
    cpln port-forward db-workload :80 --location aws-us-west-1 --org demo-org --gvc demo-gvc
    ```

    ```text Output theme={null}
    Forwarding from 127.0.0.1:56421 -> 80
    ```
  </CodeGroup>

  * Assign the same local and remote port

  <CodeGroup>
    ```bash Command theme={null}
    cpln port-forward db-workload 80 --location aws-us-west-1 --org demo-org --gvc demo-gvc
    ```

    ```text Output theme={null}
    Forwarding from 127.0.0.1:80 -> 80
    ```
  </CodeGroup>
</Accordion>

***
