# Use env variable in app

**URL:** <https://community.convox.com/t/use-env-variable-in-app/596>\
**Category:** Configuration\
**Created:** [August 31, 2019, 11:30pm UTC](https://community.convox.com/t/use-env-variable-in-app/596 "2019-08-31T23:30:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moises](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.convox.com/moises/32/97_2.png) [@moises](https://community.convox.com/u/moises)\
**Post date:** [August 31, 2019, 11:30pm UTC](https://community.convox.com/t/use-env-variable-in-app/596/1 "2019-08-31T23:30:01Z")

</div>

I’m running a Node.js app and I have setup my env variable like this:

```auto
convox env set dbHost=domain1.com

```

But in my app when I try to access the env variable like this, like I would normally do for an env variable:

```auto
{
  host: process.env.dbHost
}

```

the env variable does not exist.

I checked in my Convox Console in the Racks/Apps/{theApp}/Environment tab and I see the variable being there. I even set NODE\_ENV=production, but when I look at process.env I see NODE\_ENV set to staging which is the default for my app.

I ran also

```auto
convox releases info

```

And I see under Env my env variables

How do you access the env variable?

---

<div class="post-metadata">

**Author:** ![moises](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.convox.com/moises/32/97_2.png) [@moises](https://community.convox.com/u/moises)\
**Post date:** [September 1, 2019, 4:59pm UTC](https://community.convox.com/t/use-env-variable-in-app/596/2 "2019-09-01T16:59:04Z")

</div>

Ok, I figured it out. In order to be able to use the env variable, the variable has to be declared in the convox.yml

```auto
services:
  web:
    build: .
    port: 3000
    environment:
      - NODE_ENV
      - dbHost
      - dbName
      - dbPass
      - dbUser
    health:
      grace: 5
      interval: 5
      path: /status
      timeout: 3
    domain:
      - "*.somedomain.com"

```

---

<div class="post-metadata">

**Author:** ![ed\_convox](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.convox.com/ed_convox/32/101_2.png) [@ed\_convox](https://community.convox.com/u/ed_convox)\
**Post date:** [September 2, 2019, 10:40pm UTC](https://community.convox.com/t/use-env-variable-in-app/596/3 "2019-09-02T22:40:14Z")

</div>

Yep, that’s right, and specified in the docs.  
You can also use a wildcard if you want to bring in all the env vars if you wish: [https://docs.convox.com/application/environment#wildcard](https://docs.convox.com/application/environment#wildcard)

Hope that helps!  
Ed
