# Port Forwarding (K8s)

If you're running WarpStream in Kubernetes, you may have noticed that port-forwarding to the Agents does not work immediately. For example, if you run the follow comand in one terminal:

```
kubectl port-forward $POD_NAME 9092
```

and then run the following command in another terminal, you'll get an error:

```
warpstream cli diagnose-connection
```

You'll get an error like this:

{% code overflow="wrap" fullWidth="true" %}

```
running diagnose-connection sub-command with bootstrap-host: localhost and bootstrap-port: 9092


Broker Details
---------------
  10.212.3.4:9092 (NodeID: 206702995) [asia-southeast1-a]
failed to communicate with Agent returned as part of Kafka Metadata response, err: <nil>, this usually means that the provided bootstrap host: localhost:9092 is accessible on the current network, but the URL that the Agent is advertising as its broker host/ip: 10.212.3.4:9092 is not accessible on this network. If this is occurring during local development whilst running the Agent in a docker container, consider adding the following flag to the docker run command: --env "WARPSTREAM_PRIVATE_IP_OVERRIDE=127.0.0.1" which will force the Agent to advertise its hostname/IP address as localhost for development purposes.
```

{% endcode %}

The reason for this is that your initial client connection will reach the Agent successfully, but then the client will perform a Metadata request for service discovery and the WarpStream control plane will instruct the client to connect to other Agents using their internal IP addresses (the ones reachable in K8s, but not from your laptop). [You can read more about WarpStream service discovery in this documentation for more details](/warpstream/overview/architecture/service-discovery.md).

To work around this issue, WarpStream has a feature to instruct the service discovery system to report all the other Agents hostnames as `localhost` so that when your client performs service discovery via the Metadata request and gets redirected, it will just re-use the existing port-forward. This works because all the WarpStream Agents are stateless, none are special, and any Agent can successfully handle any Kafka protocol request.

To enable this feature from your laptop, simply add the following string to your Kafka client ID: `ws_host_override=localhost` . Using the WarpStream CLI, that would look like this:

```
warpstream cli diagnose-connection -client-id ws_host_override=localhost
```

This time it should just work, enjoy your local development experience!

{% code overflow="wrap" fullWidth="true" %}

```
running diagnose-connection sub-command with bootstrap-host: localhost and bootstrap-port: 9092


Broker Details
---------------
  LoCALHOst:9092 (NodeID: 206702995) [asia-southeast1-a]
    ACCESSIBLE ✅

  LOcALhOST:9092 (NodeID: 576636702) [asia-southeast1-b]
    ACCESSIBLE ✅

  LoCAlhost:9092 (NodeID: 1053567971) [asia-southeast1-c]
    ACCESSIBLE ✅

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.warpstream.com/warpstream/kafka/configure-kafka-client/port-forwarding-k8s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
