# Docker Filebeat 7.9.3 cannot collect metrics from http from outside the container

**URL:** <https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 30, 2020, 9:29am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792 "2020-10-30T09:29:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tisi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tisi/32/78133_2.png) [@Tisi](https://discuss.elastic.co/u/Tisi)\
**Post date:** [October 30, 2020, 9:29am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/1 "2020-10-30T09:29:30Z")

</div>

Hello Elastic Staff  
I am not able to collect metrics from filebeat from the defined http port.  
I can get the metrics from within the filebeat container with `curl -XGET localhost:5066/stats`.  
When I want to collect the metrics from my machine I get the message "Empty reply from server". The container port is published to the host at port 5066.

My Configuration:  
filebeat.yml

```auto
http.enabled: true
http.port: 5066

filebeat.config:
  modules:
    path: ${path.config}/modules.d/*.yml
    reload.enabled: false

filebeat.autodiscover:
  providers:
    - type: docker
      hints.enabled: true

processors:
- add_cloud_metadata: ~

output.elasticsearch:
  hosts: '${ELASTICSEARCH_HOSTS:elasticsearch:9200}'
  username: '${ELASTICSEARCH_USERNAME:}'
  password: '${ELASTICSEARCH_PASSWORD:}'

```

Start filebeat by command:

```auto
docker run -p "5066:5066" --name=filebeat --user=root --volume="$(pwd)/filebeat.docker.yml:/usr/share/filebeat/filebeat.yml:ro" --volume="/var/lib/docker/containers:/var/lib/docker/containers:ro" --volume="/var/run/docker.sock:/var/run/docker.sock:ro" docker.elastic.co/beats/filebeat:7.9.3 filebeat -e -strict.perms=false

```

Run `curl -XGET http://localhost:5066/stats` from my machine with the response: "curl: (52) Empty reply from server". Here I want to get the

Is there something missing that it won't work?

Best

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [October 30, 2020, 9:59am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/2 "2020-10-30T09:59:24Z")

</div>

Hi!

Can you try the curl command from inside the container to check that the endpoint is actually enabled?

Also maybe a redirection takes place so you could try adding some extra flags like `-sS` or -L.

Let me know if that helps.

C.

---

<div class="post-metadata">

**Author:** ![Tisi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tisi/32/78133_2.png) [@Tisi](https://discuss.elastic.co/u/Tisi)\
**Post date:** [October 30, 2020, 10:05am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/3 "2020-10-30T10:05:17Z")

</div>

Hi,  
thanks for your reply. I tried it from inside the container and got a response. So the endpoint should work.

I tried to run curl with the flags `-sS` and `-L` on my machine but the response is as before "Empty reply from server".

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [October 30, 2020, 10:15am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/4 "2020-10-30T10:15:42Z")

</div>

Hmm,

this is weird. Can you try with `0.0.0.0` instead of localhost?

---

<div class="post-metadata">

**Author:** ![Tisi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tisi/32/78133_2.png) [@Tisi](https://discuss.elastic.co/u/Tisi)\
**Post date:** [October 30, 2020, 10:22am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/5 "2020-10-30T10:22:01Z")

</div>

This also did not help. I now also set explicitly `server.host: "0"`. But also no change of the result.

---

<div class="post-metadata">

**Author:** ![Tisi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tisi/32/78133_2.png) [@Tisi](https://discuss.elastic.co/u/Tisi)\
**Post date:** [October 30, 2020, 10:35am UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/6 "2020-10-30T10:35:52Z")

</div>

Ok I found the solution. I missed to set the variable to `http.host: 0.0.0.0`.  
Is this the expected behavior with the docker setup? Or should it be set by default to this value for docker containers?

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [October 30, 2020, 12:45pm UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/7 "2020-10-30T12:45:27Z")

</div>

It defaults to `localhost` so I guess localhost cannot be exposed for some docker-networking reason.

---

<div class="post-metadata">

**Author:** ![Tisi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tisi/32/78133_2.png) [@Tisi](https://discuss.elastic.co/u/Tisi)\
**Post date:** [October 30, 2020, 12:49pm UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/8 "2020-10-30T12:49:09Z")

</div>

Yes I meant if it would be better for the elastic docker beat configs to default to `0.0.0.0` instead of `localhost`. For `server.host` the default in docker is already `0.0.0.0`.

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [October 30, 2020, 12:56pm UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/9 "2020-10-30T12:56:55Z")

</div>

Hmm, what exact files are you using? Where do you propose to apply this change?

---

<div class="post-metadata">

**Author:** ![Tisi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tisi/32/78133_2.png) [@Tisi](https://discuss.elastic.co/u/Tisi)\
**Post date:** [October 30, 2020, 2:37pm UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/10 "2020-10-30T14:37:55Z")

</div>

I looked up the beats repository and couldn't find what I stated. I've read at some place in this forum that it is set for elastic docker containers by default. But sadly I cannot find the topic.  
I think this topic is resolved. Thank you for your time and patience 🙂

---

<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:** [November 27, 2020, 4:38pm UTC](https://discuss.elastic.co/t/docker-filebeat-7-9-3-cannot-collect-metrics-from-http-from-outside-the-container/253792/11 "2020-11-27T16:38:01Z")

</div>

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