# Connection between Elastic Agent (on local machine) and Elasticsearch (on GCP)

**URL:** https://discuss.elastic.co/t/connection-between-elastic-agent-on-local-machine-and-elasticsearch-on-gcp/380187
**Category:** Elastic Agent
**Created:** [July 16, 2025, 4:22pm UTC](https://discuss.elastic.co/t/connection-between-elastic-agent-on-local-machine-and-elasticsearch-on-gcp/380187 "2025-07-16T16:22:18Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [July 16, 2025, 5:04pm UTC](https://discuss.elastic.co/t/connection-between-elastic-agent-on-local-machine-and-elasticsearch-on-gcp/380187/2 "2025-07-16T17:04:21Z")

</div>

Hi @Nghia_Vu Welcome to the community

> [@Nghia\_Vu](#):
>
> I was thinking of creating a cert that include this ip. But it was too much work.

Well that is the correct approach 🙂

Since this is just a study project you could enroll the Agent with the `--insecure` flag so certificate validation is not performed. Perhaps try that

> **[Elastic Agent command reference | Elastic Docs](https://www.elastic.co/docs/reference/fleet/agent-command-reference#elastic-agent-install-command)**
>
> Elastic Agent provides commands for running Elastic Agent, managing Fleet Server, and doing common tasks. The commands listed here apply to both Fleet-managed...

> `--insecure`
> 
> Allow the Elastic Agent to connect to Fleet Server over insecure connections. This setting is required in the following situations:
> 
> - When connecting to an HTTP server. The API keys are sent in clear text.
> - When connecting to an HTTPs server and the certificate chain cannot be verified. The content is encrypted, but the certificate is not verified.
> - When using self-signed certificates generated by Elastic Agent.
> 
> We strongly recommend that you use a secure connection.

You could also look through this thread

> [@\--insecure flag in fleet/elastic agent deployment to solve X509: certificate signed by unknown authority](https://discuss.elastic.co/t/insecure-flag-in-fleet-elastic-agent-deployment-to-solve-x509-certificate-signed-by-unknown-authority/363122):
>
> hello everyone, hope you're doing well i really love the elk stack and its community, much love to you guys !! i have a question : while deploying fleet or elastic agents i get this error message x509 to solved it I followed this [Troubleshoot common problems | Fleet and Elastic Agent Guide [8.14] | Elastic](https://www.elastic.co/guide/en/fleet/8.14/fleet-troubleshooting.html#agent-enrollment-certs) thanks to @stephenb basically adding --insecure flag after deployment token my question is is this just a bug that needs to be fixed and it's safe to use this approach to solve the issue o…

---

_[View the full topic](https://discuss.elastic.co/t/connection-between-elastic-agent-on-local-machine-and-elasticsearch-on-gcp/380187)._
