# Using environment variables

**URL:** <https://discuss.elastic.co/t/using-environment-variables/245621>\
**Category:** Logstash\
**Created:** [August 19, 2020, 2:27pm UTC](https://discuss.elastic.co/t/using-environment-variables/245621 "2020-08-19T14:27:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![goncalobsantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/goncalobsantos/32/50118_2.png) [@goncalobsantos](https://discuss.elastic.co/u/goncalobsantos)\
**Post date:** [August 19, 2020, 2:27pm UTC](https://discuss.elastic.co/t/using-environment-variables/245621/1 "2020-08-19T14:27:01Z")

</div>

I am trying to execute a conf file and get the following error:  
Connecion refused - failed to open TCP connection

The error does not occur when I export the http and https\_proxy variables before executing the conf file.

I've read in the documentation for [Logstash](https://www.elastic.co/guide/en/logstash/current/environment-variables.html) that: " You can set environment variable references in the configuration for Logstash plugins by using `${var}`"

However I don't understand what this means? I assume that I need to edit my conf file to add a reference to these variables, but I am not sure how to do this.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [August 19, 2020, 3:17pm UTC](https://discuss.elastic.co/t/using-environment-variables/245621/2 "2020-08-19T15:17:00Z")

</div>

Run `printenv` in your terminal. These are your enviromoment variables you can use. So if you want to use `USER` in logstash you would use `${USER}` and that would be replaced by the value when you start your pipeline.

---

<div class="post-metadata">

**Author:** ![goncalobsantos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/goncalobsantos/32/50118_2.png) [@goncalobsantos](https://discuss.elastic.co/u/goncalobsantos)\
**Post date:** [August 20, 2020, 3:08pm UTC](https://discuss.elastic.co/t/using-environment-variables/245621/3 "2020-08-20T15:08:47Z")

</div>

Thank you. That was helpful!

I've defined the HTTP and HTTPS\_PROXY variable for the logstash user.

If I undestood correctly, I should now edit my conf file. However, I'm not sure about the syntax.

The example provided in the documentation uses the tcp\_port variable. I assume that for the http, I still need to add:

http {  
proxy =\> "${HTTP\_PROXY}"  
}

within the scope of input. Is this the correct syntax?

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [August 20, 2020, 3:13pm UTC](https://discuss.elastic.co/t/using-environment-variables/245621/4 "2020-08-20T15:13:24Z")

</div>

> [@goncalobsantos](#):
>
> ${HTTP\_PROXY}

That looks corerct.

---

<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:** [September 17, 2020, 3:13pm UTC](https://discuss.elastic.co/t/using-environment-variables/245621/5 "2020-09-17T15:13:29Z")

</div>

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