# Accessing the runtime settings from a function node

**URL:** <https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242>\
**Category:** General\
**Created:** [26 January 2022 08:14 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242 "2022-01-26T08:14:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [26 January 2022 08:14 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/1 "2022-01-26T08:14:09Z")

</div>

Hi,  
Another quick obscure question (Sorry!) Is it possible to access the settings (from settings.js) in a function node?

I am trying to use the httpAdmin api to get current list of flows and I need the port for the URL.

Thanks

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [26 January 2022 09:26 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/2 "2022-01-26T09:26:07Z")

</div>

You need the port to interact with the API. You can ofcourse grep the port from the file directly, eg;  
`grep -i uiport settings.js`

---

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [26 January 2022 10:35 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/3 "2022-01-26T10:35:13Z")

</div>

Thanks for the suggestion. Does this mean the settings are not exposed to function nodes?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 January 2022 10:39 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/4 "2022-01-26T10:39:28Z")

</div>

Env variables are. So you could set `PORT` before you launch node-red then it will run on that PORT and you can access it via a function...

![chrome_SBkNyZqYwV](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fe592778a2d803316a501d825f408e00c2f7c6d2.gif)

---

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [26 January 2022 10:46 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/5 "2022-01-26T10:46:00Z")

</div>

Aha thanks......I just noticed this in another thread

> [@Port number of running node-red instance](https://discourse.nodered.org/t/port-number-of-running-node-red-instance/20166/12):
>
> In a node you should be able to access RED.settings.port.

Should This work? ie in a function node, access RED.settings?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [26 January 2022 10:53 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/6 "2022-01-26T10:53:41Z")

</div>

> [@davec1001](#):
>
> Should This work? ie in a function node,

No. When I say 'in a node' I mean a node's runtime code has access to the `RED.settings` object.

The code inside a Function node does _not_.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 January 2022 11:19 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/7 "2022-01-26T11:19:51Z")

</div>

There are lots of ways to get at the port for the Editor/admin API. For example, check whether a function node can access the browser window data which includes the current url.

Or you could pass the port to a global var from within setttings.js. Similarly you could also set the port environment variable from within settings.js as well if you don't want to mess with it externally.

---

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [26 January 2022 14:45 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/8 "2022-01-26T14:45:18Z")

</div>

Aha...ok thanks

---

<div class="post-metadata">

**Author:** ![davec1001](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@davec1001](https://discourse.nodered.org/u/davec1001)\
**Post date:** [26 January 2022 14:45 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/9 "2022-01-26T14:45:53Z")

</div>

Thanks all.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 March 2022 14:46 UTC](https://discourse.nodered.org/t/accessing-the-runtime-settings-from-a-function-node/57242/10 "2022-03-27T14:46:11Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
