# Do I need to restart the gateway after setting an ENV variable on the OS?

**URL:** <https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 6, 2026, 5:34pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905 "2026-04-06T17:34:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbranson](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kbranson](https://forum.inductiveautomation.com/u/kbranson)\
**Post date:** [April 6, 2026, 5:34pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905/1 "2026-04-06T17:34:20Z")

</div>

If I set an ENV variable on Windows do I need to restart my gateway to import that variable via:

```python
import os

api_key = os.environ['api_key']

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 6, 2026, 6:55pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905/2 "2026-04-06T18:55:15Z")

</div>

What environment variables are visible to the script/process is going to depend on:

1. Where your script is actually running (e.g. Designer script console vs a Perspective script actually running on the gateway)
2. Whether the OS is actually providing those environment variables to the running process (not a guarantee on Windows with the default service user that the Ignition process runs under)

What is the problem you are trying to solve, and why do you think environment variables are the right solution? They may be! But it's also possible they are not.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 6, 2026, 9:45pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905/3 "2026-04-06T21:45:56Z")

</div>

I think the problem being solved is storage of api keys, which has been said on the forum before to store them in environment variables. In v8.3 though these would be stored in the secrets manager, I believe.

---

<div class="post-metadata">

**Author:** ![kbranson](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kbranson](https://forum.inductiveautomation.com/u/kbranson)\
**Post date:** [April 6, 2026, 9:57pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905/4 "2026-04-06T21:57:36Z")

</div>

Unfortunately I’m on 8.1 and I can’t risk an upgrade to 8.3 at the moment as all engineering resources are tied up.

---

<div class="post-metadata">

**Author:** ![kbranson](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kbranson](https://forum.inductiveautomation.com/u/kbranson)\
**Post date:** [April 6, 2026, 9:58pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905/5 "2026-04-06T21:58:35Z")

</div>

This script is going to run on a timer as a gateway script, additionally the ENV variables were set under SYSTEM not USER so that all service accounts would have access to them.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 6, 2026, 10:05pm UTC](https://forum.inductiveautomation.com/t/do-i-need-to-restart-the-gateway-after-setting-an-env-variable-on-the-os/114905/6 "2026-04-06T22:05:53Z")

</div>

You would need to restart. Whether they are available given the OS and user account setup I don't know.
