# Get and Set Device Port Number Through Scripting

**URL:** <https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544>\
**Category:** Ignition\
**Created:** [April 1, 2025, 6:46pm UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544 "2025-04-01T18:46:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Foster](https://avatars.discourse-cdn.com/v4/letter/n/ecd19e/32.png) [@Nathan\_Foster](https://forum.inductiveautomation.com/u/Nathan_Foster)\
**Post date:** [April 1, 2025, 6:46pm UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/1 "2025-04-01T18:46:34Z")

</div>

Is there a way to get and set a device port number similar to `system.device.getDeviceHostname` and `system.device.setDeviceHostname`? In particular, for the Allen-Bradley Logix Driver. I'm fine extending the system functions with a custom module, but I'm also having trouble finding the class/methods in the Java API to do this.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 1, 2025, 6:49pm UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/2 "2025-04-01T18:49:30Z")

</div>

You cannot. Those are private to the driver. What you **can** do is delete the device instance and re-create it with the desired settings. (See my spreadsheet import tool on the exchange for code examples.)

{Technically, you could write into the internal configuration database with the right column name and value. There be dragons--a non-zero chance of crashing/freezing your gateway.}

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 1, 2025, 7:04pm UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/3 "2025-04-01T19:04:24Z")

</div>

(If you want to minimize the chance of dragons, you're likely better off writing to a backup and then restoring the gateway from snapshot, but even then you need to be careful about it. I've got a fair number of internal tools for it)

---

<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 1, 2025, 7:09pm UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/4 "2025-04-01T19:09:29Z")

</div>

It's probably tiring to hear me talk about things that will be solved in 8.3... but this entire category of problem is solved in 8.3.

All the config of all the things is completely accessible through the REST API.

---

<div class="post-metadata">

**Author:** ![Nathan\_Foster](https://avatars.discourse-cdn.com/v4/letter/n/ecd19e/32.png) [@Nathan\_Foster](https://forum.inductiveautomation.com/u/Nathan_Foster)\
**Post date:** [April 1, 2025, 7:12pm UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/5 "2025-04-01T19:12:50Z")

</div>

Since this will hopefully 🙏 🙏 🙏 be coming out soon, I'll just wait and implement a solution using 8.3. Thanks everyone!

---

<div class="post-metadata">

**Author:** ![heahxuexian](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@heahxuexian](https://forum.inductiveautomation.com/u/heahxuexian)\
**Post date:** [July 30, 2026, 9:44am UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/6 "2026-07-30T09:44:20Z")

</div>

Can I ask for the documentation for this? Could not find it anywhere. Sorry for troubling.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 30, 2026, 10:55am UTC](https://forum.inductiveautomation.com/t/get-and-set-device-port-number-through-scripting/104544/7 "2026-07-30T10:55:44Z")

</div>

The new scripting access to API targets within gateway scope is here:

> **[system.config | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-config)**
>
> API Endpoint Considerations
