# Feature Request: Environmental Variables for Port Numbers

**URL:** <https://support.prodi.gy/t/feature-request-environmental-variables-for-port-numbers/352>\
**Category:** Uncategorized\
**Tags:** enhancement, done\
**Created:** [February 27, 2018, 10:36pm UTC](https://support.prodi.gy/t/feature-request-environmental-variables-for-port-numbers/352 "2018-02-27T22:36:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![plusepsilon](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/plusepsilon/32/49_2.png) [@plusepsilon](https://support.prodi.gy/u/plusepsilon)\
**Post date:** [February 27, 2018, 10:36pm UTC](https://support.prodi.gy/t/feature-request-environmental-variables-for-port-numbers/352/1 "2018-02-27T22:36:54Z")

</div>

Currently, the port number for a Prodigy server can be changed through `prodigy.json` or the return config. It would be great if we could use an environmental variable to change the port, e.g. `PRODIGY_PORT=8081 prodigy ...`. This makes more sense when we have multiple Prodigy servers running from the same `prodigy.json`.

Thanks

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [February 27, 2018, 10:52pm UTC](https://support.prodi.gy/t/feature-request-environmental-variables-for-port-numbers/352/2 "2018-02-27T22:52:51Z")

</div>

That’s a good idea, thanks! I think it’d make sense to first check for the environment variable, then the `prodigy.json` and if none are set, default to `8080`. This would let you set a custom default port globally or per project, and overwrite it on the command line if necessary.

In the meantime, you can always add this functionality in the `server` function in Prodigy’s `app.py`:

```python
port = os.getenv('PRODIGY_PORT', config.get('port', 8080))

```

For consistency, we should probably add the same for the `host` setting.

---

<div class="post-metadata">

**Author:** ![plusepsilon](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/plusepsilon/32/49_2.png) [@plusepsilon](https://support.prodi.gy/u/plusepsilon)\
**Post date:** [February 27, 2018, 11:36pm UTC](https://support.prodi.gy/t/feature-request-environmental-variables-for-port-numbers/352/3 "2018-02-27T23:36:26Z")

</div>

Yes, that makes sense.

We currently have gnarly wrapper around `plac` to automatically inject a port number into the config 🙂

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [March 11, 2018, 5:46pm UTC](https://support.prodi.gy/t/feature-request-environmental-variables-for-port-numbers/352/4 "2018-03-11T17:46:15Z")

</div>

Implemented in `v1.4.0` 🎉 You can now set a `PRODIGY_PORT` and `PRODIGY_HOST` environment variable, which overwrites all other settings. I’ve also added a section to the README that lists all available environment variables for reference.
