# Unable to access environment variables in Travis CI

**URL:** <https://travis-ci.community/t/unable-to-access-environment-variables-in-travis-ci/12801>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** travis-build\
**Created:** [March 13, 2022, 10:13pm UTC](https://travis-ci.community/t/unable-to-access-environment-variables-in-travis-ci/12801 "2022-03-13T22:13:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pydare](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/pydare/32/7777_2.png) [@Pydare](https://travis-ci.community/u/Pydare)\
**Post date:** [March 13, 2022, 10:13pm UTC](https://travis-ci.community/t/unable-to-access-environment-variables-in-travis-ci/12801/1 "2022-03-13T22:13:09Z")

</div>

Hi,

This is my first time using the Travis CI tool or any CI/CD tool.

I am using my .travis.yml file to run some unit tests I have written which require my Mongo URI which is stored in my environment variable (.env file).

I read the documentation on how to encrypt private environment variables ([travis-ci.com](http://travis-ci.com)) and followed everything.

My tests pass locally but on the Travis CI pipeline, it is unable to access the environment variable which I have encrypted, which is my Mongo URI.

This is what my .travis.yml file looks like

```auto
language: node_js
node_js: 17.4.0
env:
  global:
  - secure: encrypted_token
script:
- echo ' *******Build starts********'
- echo 'Installing dependencies'
- npm install
- echo 'Running tests'
- npm test

```

I’d appreciate some help. Thanks.

---

<div class="post-metadata">

**Author:** ![mustafaergul](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/mustafaergul/32/7814_2.png) [@mustafaergul](https://travis-ci.community/u/mustafaergul)\
**Post date:** [March 28, 2022, 8:27am UTC](https://travis-ci.community/t/unable-to-access-environment-variables-in-travis-ci/12801/2 "2022-03-28T08:27:55Z")

</div>

Hey,

Once you encrypt the environment variable you will need to access like `echo $foo` notation. Travis CI is not using the .env file that you have in your repository.

Thanks,  
Mustafa  
Travis CI Staff
