---
title: pydo.harness.get_session_port_forward()
description: PortForwardSession opens a WebSocket tunnel to a guest TCP port.
product: Reference
url: https://docs.digitalocean.com/reference/pydo/reference/harness/get_session_port_forward/
last_updated: "2026-11-20"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# pydo.harness.get_session_port_forward()

Generated on 20 Nov 2026 from `pydo` version [`v0.47.0`](https://github.com/digitalocean/pydo/releases/tag/v0.47.0)

## Usage

```python
client.harness.get_session_port_forward(
    session_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    port=8000,
)
```

Returns `JSON` Raises `HttpResponseError`

## Description

Upgrades the request to a WebSocket and bridges it to one TCP connection on the session sandbox’s guest `port`. Binary frames carry the opaque byte stream in both directions; the server closes with a descriptive WebSocket close code when the tunnel ends. This is the raw TCP tunnel; browser clients reaching the in-guest OpenHands Agent Server use the ingress URL (`GET /v2/harness-runtime/sessions/{session_id}/ingress`), which has replaced this bridge for them.

WebSocket is not expressible in OpenAPI; this documents the GET that initiates the upgrade handshake (HTTP 101 Switching Protocols). The handler dials the guest before upgrading, so a PAUSED session is woken and served rather than rejected. `port` must be between 1024 and 65535. A request without the WebSocket upgrade headers is answered 400 by the handshake layer.

## Parameters

`session_id` string required

Example: `a1b2c3d4-e5f6-7890-abcd-ef1234567890`

The session UUID.

`port` integer required

Example: `8000`

The guest TCP port to connect to. Must be between 1024 and 65535.

Min: `1024`

Max: `65535`

## More Information

See [`/v2/harness-runtime/sessions/{session_id}/port-forward/{port}`](https://docs.digitalocean.com/reference/api/reference/harness-runtime/index.html.md#harness_get_session_port_forward) in the API reference for additional detail on responses, headers, parameters, and more.