# TCP port field error when defined as a variable

**URL:** https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168
**Category:** General
**Created:** [22 March 2025 05:47 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168 "2025-03-22T05:47:38Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![JonnyTech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jonnytech/32/93759_2.png) [@JonnyTech](https://discourse.nodered.org/u/JonnyTech)
#### Post date: [22 March 2025 05:47 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/1 "2025-03-22T05:47:38Z")

</div>

In my flow properties I set some environment variables (strings):  
device-ip = 10.10.10.10  
device-port = 12345

Then I add a TCP request node and set its properties:  
Server = ${device-ip}  
Port = ${device-port}

(There are reasons for this which I won't get into now)

This works correctly, but the port field generates an error every time that I deploy (The workspace contains some nodes that are not properly configured).

How can I ignore the error seeing as it works as expected?

Node-RED v4.0.9

---

<div class="post-metadata">

### Author: ![JonnyTech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jonnytech/32/93759_2.png) [@JonnyTech](https://discourse.nodered.org/u/JonnyTech)
#### Post date: [26 March 2025 10:41 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/2 "2025-03-26T10:41:05Z")

</div>

Can someone who is familiar with the node-red source code point me towards the relevant section where the fields are checked at the deploy stage, so that I can create a pull request to make the "port" field behave the same as the "server" field, thus eliminating this annoying bogus error message.

---

<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 March 2025 10:59 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/3 "2025-03-26T10:59:58Z")

</div>

> <https://github.com/node-red/node-red/blob/23c44db30d0a97ca4ae86a4e56627272a0f8723b/packages/node_modules/%40node-red/nodes/core/network/31-tcpin.html#L86>

---

<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 March 2025 11:02 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/4 "2025-03-26T11:02:10Z")

</div>

Before raising a PR, please [raise an issue](https://github.com/node-red/node-red/issues/new/choose) and provide all the necessary info (and demo flow) (and potentially a gif or short video that demonstrates what you are seeing).

---

<div class="post-metadata">

### Author: ![JonnyTech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jonnytech/32/93759_2.png) [@JonnyTech](https://discourse.nodered.org/u/JonnyTech)
#### Post date: [26 March 2025 17:59 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/5 "2025-03-26T17:59:51Z")

</div>

Done: [issue #5093](https://github.com/node-red/node-red/issues/5093)

---

<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 March 2025 18:07 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/6 "2025-03-26T18:07:51Z")

</div>

Thanks.

I replied to your issue:

> FWIW, It's generally considered best practice to stick to uppercase letters and underscores.
> 
> REF: [Environment Variables](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html)
> 
> In fact, if you defined your env vars in the more traditional way (e.g. `TCP_PORT`) this does not happen
> 
> [![Image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/2/b2b227ab490bf91dba28bfe0bb9840b13b9762f5.png)](https://private-user-images.githubusercontent.com/44235289/427162555-5cdb80c0-2494-4b2e-b4ec-9184d480e4fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDMwMTI2NjQsIm5iZiI6MTc0MzAxMjM2NCwicGF0aCI6Ii80NDIzNTI4OS80MjcxNjI1NTUtNWNkYjgwYzAtMjQ5NC00YjJlLWI0ZWMtOTE4NGQ0ODBlNGZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAzMjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMzI2VDE4MDYwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc5YzQ2NmRlODRmNzQ3ZWYzNmExZDY2YTM5ZTdiODE0MmNmZDUyY2YxMTMxZWNjMDZkMGExMDRmMWNmM2NjZWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.k9jOKGXXWW1Lnt5Sz6DCir6Y5LLcEC-shgOquokfL0M)

So you can move forwards today if you wish.

The fact Node-RED correctly evaluates `tcp-ip` today means the likely fix is to improve the numeric validator.

---

<div class="post-metadata">

### Author: ![JonnyTech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jonnytech/32/93759_2.png) [@JonnyTech](https://discourse.nodered.org/u/JonnyTech)
#### Post date: [26 March 2025 18:26 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/7 "2025-03-26T18:26:44Z")

</div>

Thank you @Steve-Mcl - I really appreciate your time and advice.

---

<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: [24 June 2025 18:27 UTC](https://discourse.nodered.org/t/tcp-port-field-error-when-defined-as-a-variable/96168/8 "2025-06-24T18:27:32Z")

</div>

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