# Expose logstash API to host

**URL:** <https://discuss.elastic.co/t/expose-logstash-api-to-host/130067>\
**Category:** Logstash\
**Created:** [April 30, 2018, 9:16pm UTC](https://discuss.elastic.co/t/expose-logstash-api-to-host/130067 "2018-04-30T21:16:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajisankar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajisankar/32/43250_2.png) [@rajisankar](https://discuss.elastic.co/u/rajisankar)\
**Post date:** [April 30, 2018, 9:16pm UTC](https://discuss.elastic.co/t/expose-logstash-api-to-host/130067/1 "2018-04-30T21:16:16Z")

</div>

I am running Logstash 5.5 in a docker container. Since Logstash API binds to port 9600, i expose the port in the container hoping to access API endpoints from the host. Also, i am running metricbeat on the host to collect logstash stats.

$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
999b11cdd236 ccur/logstash:latest "/docker-entrypoin..." About an hour ago Up About an hour 0.0.0.0:5044-\>5044/tcp, 0.0.0.0:9600-\>9600/tcp, 0.0.0.0:5001-\>5000/tcp logstash

I am unable to access the api from host. I get the following error from metricbeat

**"message": "error making http request: Get [http://10.76.144.21:9600/\_node/stats:](http://10.76.144.21:9600/_node/stats:) dial tcp 10.76.144.21:9600: getsockopt: connection refused"**

Even, a simple curl command fails.  
$ curl -XGET '127.0.0.1:9600/\_node/stats?pretty'  
curl: (56) Recv failure: Connection reset by peer

Any pointers would be appreciated.

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [April 30, 2018, 9:40pm UTC](https://discuss.elastic.co/t/expose-logstash-api-to-host/130067/2 "2018-04-30T21:40:00Z")

</div>

Are you using one of the official Logstash distributions for Docker, or are you building your own?

By default, the Logstash API binds only to the local loopback interface (e.g., `127.0.0.1`), and not to external interfaces.

The Elastic-provided docker distribution [binds to all interfaces via `0.0.0.0`](https://www.elastic.co/guide/en/logstash/current/docker-config.html#_docker_defaults); if you're dockerising your own, you can set `http.host` as we do.

A warning, though: the API binds to local loopback for security reasons; as an unsecured localhost-only API, it is not subject to as much security-related scrutiny while in development. I would strongly advise limiting its exposure via your network as much as is reasonable.

---

<div class="post-metadata">

**Author:** ![rajisankar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajisankar/32/43250_2.png) [@rajisankar](https://discuss.elastic.co/u/rajisankar)\
**Post date:** [April 30, 2018, 10:08pm UTC](https://discuss.elastic.co/t/expose-logstash-api-to-host/130067/3 "2018-04-30T22:08:07Z")

</div>

Brilliant. That worked like a charm. 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:** [May 28, 2018, 10:08pm UTC](https://discuss.elastic.co/t/expose-logstash-api-to-host/130067/4 "2018-05-28T22:08:11Z")

</div>

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