# How to point a workflow client or a worker to the remote instance of Temporal server?

**URL:** <https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [February 2, 2021, 8:50am UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423 "2021-02-02T08:50:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArtyomS](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@ArtyomS](https://community.temporal.io/u/ArtyomS)\
**Post date:** [February 2, 2021, 8:50am UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/1 "2021-02-02T08:50:17Z")

</div>

Hello everyone,  
The WorkflowServiceStubs is always used in java examples:

```
// WorkflowServiceStubs is a gRPC stubs wrapper that talks to the local Docker instance of the Temporal server.
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();

```

Do you have an example of how to connect to a remote Temporal server?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 2, 2021, 5:04pm UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/2 "2021-02-02T17:04:22Z")

</div>

```auto
    WorkflowServiceStubs service =
        WorkflowServiceStubs.newInstance(
            WorkflowServiceStubsOptions.newBuilder().setTarget("host:port").build());

```

---

<div class="post-metadata">

**Author:** ![ArtyomS](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@ArtyomS](https://community.temporal.io/u/ArtyomS)\
**Post date:** [February 8, 2021, 11:58am UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/3 "2021-02-08T11:58:06Z")

</div>

Thanks a lot @maxim .

---

<div class="post-metadata">

**Author:** ![cg1972](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/cg1972/32/465_2.png) [@cg1972](https://community.temporal.io/u/cg1972)\
**Post date:** [February 10, 2021, 9:23pm UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/4 "2021-02-10T21:23:45Z")

</div>

Hi Maxim,

```
In a K8 environment where both temporal and the service wanting to connect to temporal were both running in the default namespace would the "host:port" be the `temporal-frontend` or `temporal-frontend-headless` service that needs to be connect to? e.g .setTarget("http://temporal-frontend:7233")
```

---

<div class="post-metadata">

**Author:** ![derek](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/derek/32/245_2.png) [@derek](https://community.temporal.io/u/derek)\
**Post date:** [February 10, 2021, 11:01pm UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/5 "2021-02-10T23:01:41Z")

</div>

Either one would work with the difference is in how clients will end up being routed to specific frontend pods.

That said, the `headless` version of the service is more for service discovery (IPs of each pod) and the non-headless frontend provides an internally load balanced service (1 ip that is balanced across all available pods).

So the recommendation here would be to use the non-headless version unless you want clients to talk to specific frontends for some reason (not normally something you want to do).

---

<div class="post-metadata">

**Author:** ![cg1972](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/cg1972/32/465_2.png) [@cg1972](https://community.temporal.io/u/cg1972)\
**Post date:** [February 11, 2021, 12:28am UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/6 "2021-02-11T00:28:52Z")

</div>

Thanks Derek.

---

<div class="post-metadata">

**Author:** ![Faizan\_Kamal](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Faizan\_Kamal](https://community.temporal.io/u/Faizan_Kamal)\
**Post date:** [June 23, 2021, 4:38pm UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/7 "2021-06-23T16:38:25Z")

</div>

Hi @maxim ,

I tried the same way for Temporal server in Docker image in a different machine.  
I am able to the see the emporal Ui but this code gives me connection error.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [June 23, 2021, 4:44pm UTC](https://community.temporal.io/t/how-to-point-a-workflow-client-or-a-worker-to-the-remote-instance-of-temporal-server/1423/8 "2021-06-23T16:44:26Z")

</div>

The `target` is passed to gRPC directly. You might need a different format in your case. Here is [the list of possible formats](https://grpc.github.io/grpc/core/md_doc_naming.html).

Accessing docker based services from another machine requires special network configuration. I would consult with docker-compose/docker documentation.
