# Setting variable http.port

**URL:** <https://discuss.elastic.co/t/setting-variable-http-port/182429>\
**Category:** Elasticsearch\
**Created:** [May 23, 2019, 12:14pm UTC](https://discuss.elastic.co/t/setting-variable-http-port/182429 "2019-05-23T12:14:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leobaiano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leobaiano/32/43704_2.png) [@leobaiano](https://discuss.elastic.co/u/leobaiano)\
**Post date:** [May 23, 2019, 12:14pm UTC](https://discuss.elastic.co/t/setting-variable-http-port/182429/1 "2019-05-23T12:14:39Z")

</div>

I need to set the http port dynamically using an environment variable to run my docker container on heroku, for that purpose I added the code below in my Dockerfile:

`CMD ["elasticsearch","-Ehttp.port=$PORT"]`

It seems that heroku does the job of passing the door through the environment variable because I get the message below in the log:

`Starting process with command` elasticsearch -Ehttp.port \ = \ 10323`

But soon after I get the error:

`org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: invalid port range: $ PORT`

My Dockerfile is simple, just create an image from elasticsearch: 6.7.1 and copy a new jvm.options and elasticsearch.yml to customize, so I do not think it's necessary to copy the code here, but I'll do it if I have to.

Has anyone ever had anything like this or do you have any idea what I might be doing wrong?

Thank you very much.

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [May 31, 2019, 1:54pm UTC](https://discuss.elastic.co/t/setting-variable-http-port/182429/2 "2019-05-31T13:54:44Z")

</div>

Hi @leobaiano,

Could you try using `${PORT}` instead, please?

Cheers,  
Luiz Santos

---

<div class="post-metadata">

**Author:** ![leobaiano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leobaiano/32/43704_2.png) [@leobaiano](https://discuss.elastic.co/u/leobaiano)\
**Post date:** [May 31, 2019, 2:33pm UTC](https://discuss.elastic.co/t/setting-variable-http-port/182429/3 "2019-05-31T14:33:00Z")

</div>

> [@leobaiano](#):
>
> CMD ["elasticsearch","-Ehttp.port=$PORT"]

@luiz.santos,

I managed to resolve this issue, but then the elasticsearch stopped responding unexpectedly and the heroku ended the process.

The question here is that if you use the command in a list ([...]) the variable `$ PORT` is not interpreted, so the error` invalid port range: $ PORT`, to solve it just remove the list so :

`CMD elasticsearch -Ettp.port = $ PORT`

Even using `{$ PORT}` within the list would not interpret.

I still can not run elasticsearch nor kibana on heroku via Dockerfile, I always encounter one of its errors. With the kibana now it is giving timeout in the response of the door, even I defining the door with the variable of their environment.

Thank you very much for the answer, if anyone can close the topic, because I can not.

---

<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:** [June 28, 2019, 2:33pm UTC](https://discuss.elastic.co/t/setting-variable-http-port/182429/4 "2019-06-28T14:33:09Z")

</div>

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