# Change Elastic Agent GRPC port via Environment Variable?

**URL:** <https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014>\
**Category:** Elastic Agent\
**Created:** [July 29, 2022, 6:51pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014 "2022-07-29T18:51:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [July 29, 2022, 6:51pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014/1 "2022-07-29T18:51:57Z")

</div>

Hi All,

I was wonder if there is a way to change the GRPC port the Elastic Agent uses via an environment variable.

Use case:

I have a Kubernetes cluster that runs with a complete underlying OS, because of this, I run an Elastic Agent on the OS to have things like Endpoint Security run on it. I would like to deploy an Elastic Agent daemonSet to the Kubernetes cluster so that I can use the [Kubernetes integration](https://docs.elastic.co/integrations/kubernetes). To take full advantage of the Kubernetes integration, I need to deploy the daemonSet with `hostNetwork: true`, the issue is that since I already have an Elastic Agent deployed on the OS level, I get an error as the GRPC port is already in use.

I'd like to change the GRPC port of the daemonSet deployment and setting an environment variable would be the easiest, but I can't seem to find if there is an environment variable to do this. Would anyone know if this exists?

Note: This would really be a gap filling solution until Endpoint Security is [supported](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-elastic-agent-fleet-known-limitations.html#k8s_running_endpoint_security_integration) via a Kubernetes deployment

---

<div class="post-metadata">

**Author:** ![ferullo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ferullo/32/74240_2.png) [@ferullo](https://discuss.elastic.co/u/ferullo)\
**Post date:** [July 29, 2022, 7:34pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014/2 "2022-07-29T19:34:01Z")

</div>

Hi @BenB196 . Sorry, but the port cannot be configured currently. We are considering an improvement for this because of the type of problem you're seeing.

---

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [July 29, 2022, 7:36pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014/3 "2022-07-29T19:36:15Z")

</div>

Thanks @ferullo for the information, by chance is there a public GitHub issue to follow along for this?

---

<div class="post-metadata">

**Author:** ![ferullo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ferullo/32/74240_2.png) [@ferullo](https://discuss.elastic.co/u/ferullo)\
**Post date:** [July 29, 2022, 7:42pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014/4 "2022-07-29T19:42:49Z")

</div>

There wasn't before, but now there is 🙂 [Allow the Agent\<-\>Endpoint local relay port to be changed · Issue #817 · elastic/elastic-agent · GitHub](https://github.com/elastic/elastic-agent/issues/817)

---

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [July 29, 2022, 7:47pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014/5 "2022-07-29T19:47:56Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 26, 2022, 7:48pm UTC](https://discuss.elastic.co/t/change-elastic-agent-grpc-port-via-environment-variable/311014/6 "2022-08-26T19:48:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
