# Using Environment Variables in a Service File

**URL:** <https://forums.balena.io/t/using-environment-variables-in-a-service-file/945>\
**Category:** Product support\
**Tags:** systemd\
**Created:** [May 11, 2017, 2:29pm UTC](https://forums.balena.io/t/using-environment-variables-in-a-service-file/945 "2017-05-11T14:29:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bunbury](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bunbury](https://forums.balena.io/u/bunbury)\
**Post date:** [May 11, 2017, 2:29pm UTC](https://forums.balena.io/t/using-environment-variables-in-a-service-file/945/1 "2017-05-11T14:29:07Z")

</div>

I have a systemd service that runs a python script which requires an environment variable that I have defined through resin. When I run the script from the command line, it runs absolutely fine. Yet when run through a service, the script fails. From what I have read systemd services are not able to access environment variables, is there a way around this?

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [May 11, 2017, 2:59pm UTC](https://forums.balena.io/t/using-environment-variables-in-a-service-file/945/3 "2017-05-11T14:59:48Z")

</div>

💬You can read the env vars from `/etc/docker.env`

---

<div class="post-metadata">

**Author:** ![bunbury](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@bunbury](https://forums.balena.io/u/bunbury)\
**Post date:** [May 11, 2017, 3:49pm UTC](https://forums.balena.io/t/using-environment-variables-in-a-service-file/945/4 "2017-05-11T15:49:55Z")

</div>

Awesome this works perfectly.
