# How do I run ysqlsh or psql queries externally?

**URL:** <https://forum.yugabyte.com/t/how-do-i-run-ysqlsh-or-psql-queries-externally/655>\
**Category:** General\
**Created:** [March 21, 2020, 2:58pm UTC](https://forum.yugabyte.com/t/how-do-i-run-ysqlsh-or-psql-queries-externally/655 "2020-03-21T14:58:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CharlieORiley](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@CharlieORiley](https://forum.yugabyte.com/u/CharlieORiley)\
**Post date:** [March 21, 2020, 2:58pm UTC](https://forum.yugabyte.com/t/how-do-i-run-ysqlsh-or-psql-queries-externally/655/1 "2020-03-21T14:58:17Z")

</div>

I started a yugabyte cluster in minikube using the helm chart in [Deploy | YugabyteDB Docs](https://docs.yugabyte.com/latest/deploy/kubernetes/oss/helm-chart/) - how can I run psql or ysqlsh queries against this cluster from outside? I don’t see the load balancer specified in the page.

---

<div class="post-metadata">

**Author:** ![karthik](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/karthik/32/13_2.png) [@karthik](https://forum.yugabyte.com/u/karthik)\
**Post date:** [March 22, 2020, 3:51am UTC](https://forum.yugabyte.com/t/how-do-i-run-ysqlsh-or-psql-queries-externally/655/2 "2020-03-22T03:51:55Z")

</div>

Hi @CharlieORiley,

You can use port forwarding I believe. For example, you could do one of the following.

- Forward the ports for the entire `yb-tserver` service:

- Forward the ports from just one pod:

Subsequently, you can run `psql` or `ysqlsh` pointing to `localhost` port `5433` as follows:

```auto
ysqlsh -h localhost -p 5433

```

#### NOTE #1: Get the exact service name by running the following commands:

```auto
kubectl get pods -A
kubectl get svc -A`

```

#### NOTE #2: The port 5433 needs to be unused on the machine.

If it is already in use, you could get an error as follows:

```auto
❯ kubectl port-forward svc/yb-tservers 5433:5433

Unable to listen on port 5433: 
Listeners failed to create with the following errors: 
  [unable to create listener: 
     Error listen tcp4 127.0.0.1:5433: 
       bind: address already in use unable to create listener: 
     Error listen tcp6 [::1]:5433: bind: address already in use
  ]
error: unable to listen on any of the requested ports: [{5433 5433}]

```

#### NOTE #3: Use a Kubernetes load balancer in production

In production. you would typically use a [kubernetes load balancer as described in our docs](https://docs.yugabyte.com/latest/deploy/kubernetes/oss/helm-chart/#connect-using-external-clients).

Hope that helps. cc @sanketh @arnav in case I have something wrong.

---

<div class="post-metadata">

**Author:** ![asevans48](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/asevans48/32/243_2.png) [@asevans48](https://forum.yugabyte.com/u/asevans48)\
**Post date:** [August 5, 2020, 5:45am UTC](https://forum.yugabyte.com/t/how-do-i-run-ysqlsh-or-psql-queries-externally/655/3 "2020-08-05T05:45:20Z")

</div>

I keep getting connection refused when running from pgadmin4. Has anyone encountered this?

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [August 7, 2020, 8:33am UTC](https://forum.yugabyte.com/t/how-do-i-run-ysqlsh-or-psql-queries-externally/655/4 "2020-08-07T08:33:43Z")

</div>

@asevans48 This was fixed in thread [Cannot seem to connect on minikube at forwarded port - #2 by dorian\_yugabyte](https://forum.yugabyte.com/t/cannot-seem-to-connect-on-minikube-at-forwarded-port/787/2).
