# How to specify unicast.hosts from environment variable?

**URL:** <https://discuss.elastic.co/t/how-to-specify-unicast-hosts-from-environment-variable/66741>\
**Category:** Elasticsearch\
**Created:** [November 21, 2016, 3:12pm UTC](https://discuss.elastic.co/t/how-to-specify-unicast-hosts-from-environment-variable/66741 "2016-11-21T15:12:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)\
**Post date:** [November 21, 2016, 3:12pm UTC](https://discuss.elastic.co/t/how-to-specify-unicast-hosts-from-environment-variable/66741/1 "2016-11-21T15:12:25Z")

</div>

Hi,

I would like to specify the master list via an environment variable, like this:  
network.bind\_host: ["${ES\_HOST}","127.0.0.1"]  
(this works)

What I try is the following:  
export ES\_MASTER\_PORT=$((9300+$ES\_MASTER\_OFFSET))  
export ES\_MASTERS="["10.6.145.219:${ES\_MASTER\_PORT}","10.6.145.220:${ES\_MASTER\_PORT}","10.6.145.221:${ES\_MASTER\_PORT}"]"

And this in elasticsearch.yml:  
discovery.zen.ping.unicast.hosts: "${ES\_MASTERS}"

What I get is this:  
Exception in thread "main" java.lang.IllegalArgumentException: Failed to resolve address for [["10.6.145.219:9300"]  
Likely root cause: java.lang.IllegalArgumentException: Invalid bracketed host/port range: ["10.6.145.219:9300"  
at org.elasticsearch.transport.netty.NettyTransport.parse(NettyTransport.java:718)  
at org.elasticsearch.transport.netty.NettyTransport.addressesFromString(NettyTransport.java:696)  
at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:424)  
at org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing.(UnicastZenPing.java:160)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
at \<\<\>\>  
at org.elasticsearch.node.Node.(Node.java:213)  
at org.elasticsearch.node.Node.(Node.java:140)  
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:143)  
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194)  
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286)  
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

Is it possible to achieve this somehow?

---

<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:** [December 19, 2016, 3:12pm UTC](https://discuss.elastic.co/t/how-to-specify-unicast-hosts-from-environment-variable/66741/2 "2016-12-19T15:12:26Z")

</div>

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