# Why doesn't node.name default to hostname

**URL:** <https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180>\
**Category:** Elasticsearch\
**Created:** [July 12, 2019, 9:00am UTC](https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180 "2019-07-12T09:00:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefws](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefws/32/6442_2.png) [@stefws](https://discuss.elastic.co/u/stefws)\
**Post date:** [July 12, 2019, 9:00am UTC](https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180/1 "2019-07-12T09:00:47Z")

</div>

Trying to add a new node to a cluster only it doesn't seem to default node.name to hostname but rather a random string. Shouldn't it default to hostname?

```
[2019-07-12T10:55:05,152][INFO][o.e.n.Node] [_u9qFWr] started
[root@es-i1 elasticsearch]# hostname
es-i1
```

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 12, 2019, 9:09am UTC](https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180/2 "2019-07-12T09:09:49Z")

</div>

It depends which version you are using. Defaulting `node.name` to the hostname was added in 7.0

> <https://github.com/elastic/elasticsearch/pull/33677>

Prior to 7.0 it uses a prefix of the persistent node ID by default.

---

<div class="post-metadata">

**Author:** ![stefws](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefws/32/6442_2.png) [@stefws](https://discuss.elastic.co/u/stefws)\
**Post date:** [July 12, 2019, 9:22am UTC](https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180/3 "2019-07-12T09:22:41Z")

</div>

Okay thanks, I'm on 6.8.1, that figures then, it's just a nicer feature in 7 🙂 as it's a hazzle not to be able to share config file for multiple nodes.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 12, 2019, 9:36am UTC](https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180/4 "2019-07-12T09:36:52Z")

</div>

You can [use environment variables in the config file](https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#_environment_variable_substitution) to achieve the same effect:

```auto
node.name: ${HOSTNAME}

```

---

<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 9, 2019, 9:36am UTC](https://discuss.elastic.co/t/why-doesnt-node-name-default-to-hostname/190180/5 "2019-08-09T09:36:57Z")

</div>

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