# Cannot connect to elasticsearch, via functionbeat(using AWS Lambda)

**URL:** <https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-functionbeat-using-aws-lambda/337657>\
**Category:** Elasticsearch\
**Created:** [July 5, 2023, 10:42am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-functionbeat-using-aws-lambda/337657 "2023-07-05T10:42:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kavan\_Dalwadi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kavan_dalwadi/32/123061_2.png) [@Kavan\_Dalwadi](https://discuss.elastic.co/u/Kavan_Dalwadi)\
**Post date:** [July 5, 2023, 10:42am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-functionbeat-using-aws-lambda/337657/1 "2023-07-05T10:42:39Z")

</div>

Currently I have deployed Elasticstack (ELK) on AWS EKS and Im using NodePort service for all the application  
My elasticsearch is running at- 54.2xx.xxx.xxx:30092/ (Which is the public IP address of EC2).  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/e/0ecbb8b89d1dd982b402427abea36dbd7edea25b.png)

I have lambda function for functionbeat which is running in the same VPC, in a **Private subnet** with a NAT gateway.

I tried to connect with elasticsearch using Public and Private IP for EC2 instance but it is giving me error-

1. `Error dialing dial tcp 172.xx.xxx.190:30092: i/o timeout`

2. `Failed to connect to backoff(elasticsearch(http://172.xx.xxx.190:30092)): Get \"http://172.xx.xxx.190:30092\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)`

I have tried elasticsearch output config as-

```auto
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["172.31.xxx.190:30092"]

  # Protocol - either `http` (default) or `https`.
  protocol: "http"

```

and

```auto
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["54.242.xxx.146:30092"]

  # Protocol - either `http` (default) or `https`.
  protocol: "http"

```

---

<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 2, 2023, 10:42am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-via-functionbeat-using-aws-lambda/337657/2 "2023-08-02T10:42:49Z")

</div>

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