# Mac hostname showing as "localhost"

**URL:** <https://discuss.elastic.co/t/mac-hostname-showing-as-localhost/105465>\
**Category:** Beats\
**Created:** [October 26, 2017, 6:09pm UTC](https://discuss.elastic.co/t/mac-hostname-showing-as-localhost/105465 "2017-10-26T18:09:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsaeks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rsaeks/32/5068_2.png) [@rsaeks](https://discuss.elastic.co/u/rsaeks)\
**Post date:** [October 26, 2017, 6:09pm UTC](https://discuss.elastic.co/t/mac-hostname-showing-as-localhost/105465/1 "2017-10-26T18:09:27Z")

</div>

I've been running into an interesting issue and it sounds like in the past there was a similar challenge running a beat on a mac. In my case this is filebeat, but the symptom is the same as @DPattee reported here:

> [@Mac hostname showing as 'localhost'](https://discuss.elastic.co/t/mac-hostname-showing-as-localhost/48878):
>
> Two Mac OS X machines set up to report statistics via TopBeat 1.2.1 (amd64). One of those machines is the one that Elastic runs on. Same topbeat config file on both machines. The elastic search: hosts: line is set to the ip address ([http://nn.nn.nn.nn:9200](http://nn.nn.nn.nn:9200)), neither is using the default "localhost" option. The shipper: name: line is left commented out so that each machine should automatically report the hostname. One machine, the remote one running OS X 10.11.4, correctly reports the beat.h…

I'm using a launchDaemon to start filebeat at system startup. When this happens machines seem to want to report back "localhost" as the machine name via filebeat even though all other system tools show the proper hostname.

Sure enough, as soon as I kill filebeat (and it re-launches) the proper hostname begins reporting back. I wasn't sure if anyone has put together a workaround other than restarting the agent, but wanted to share one I've done:

As part of the filebeat install we run a postinstall script to add in and load the launchDaemon. I added in a line of code to:

echo "name: "`hostname` | cut -d "." -f1 \>\> /usr/local/filebeat/filebeat.yml

This puts sets what eventually appears as beat.name to the machine name trimming out .local and stores the data into the filebeat.yml config file.

Hope this helps some and if there are some better ways I'm happy to hear!

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [October 26, 2017, 11:01pm UTC](https://discuss.elastic.co/t/mac-hostname-showing-as-localhost/105465/2 "2017-10-26T23:01:15Z")

</div>

Probably the beat is starting before the networking system is fully up. I think all Beats only retrieve the hostname once at startup. It might make sense to have to Beat periodically check to see if the hostname has changed.

---

<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 16, 2017, 6:09pm UTC](https://discuss.elastic.co/t/mac-hostname-showing-as-localhost/105465/3 "2017-11-16T18:09:37Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
