# \[TLJH\] How to set env vars for users \_after\_ but not for the spawner?

**URL:** <https://discourse.jupyter.org/t/tljh-how-to-set-env-vars-for-users-after-but-not-for-the-spawner/6725>\
**Category:** JupyterHub\
**Created:** [November 13, 2020, 7:36am UTC](https://discourse.jupyter.org/t/tljh-how-to-set-env-vars-for-users-after-but-not-for-the-spawner/6725 "2020-11-13T07:36:22Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)\
**Post date:** [March 24, 2021, 11:56am UTC](https://discourse.jupyter.org/t/tljh-how-to-set-env-vars-for-users-after-but-not-for-the-spawner/6725/4 "2021-03-24T11:56:22Z")

</div>

Does setting `no_proxy` to include the hub ip work? On TLJH, that should be 127.0.0.1, I believe, so this config:

```python
c.Spawner.environment = {
  "http_proxy": "http://your proxy",
  "https_proxy": "https://your proxy",
  "no_proxy": "127.0.0.1,localhost",
}

```

ought to work, assuming the http client(s) in question supports $no\_proxy. Which are they, btw?

If you still need to, kernelspecs can define an `env` dict to specify any environment variables that should be set when launching the kernel, for example:

```json
{
 "argv": ["python3", "-m", "IPython.kernel",
          "-f", "{connection_file}"],
 "display_name": "Python 3",
 "language": "python",
 "env": {"http_proxy": "..."}
}

```

so patching kernelspec .json files is one way to set envs. Another is to subclass MappingKernelManager, extending `.start_kernel()` to pass additional env variables at kernel start time.

But modifying kernelspecs won’t affect terminals, so the `no_proxy` exception for the hub ip is probably preferable, if it works.

---

_[View the full topic](https://discourse.jupyter.org/t/tljh-how-to-set-env-vars-for-users-after-but-not-for-the-spawner/6725)._
