# Disable an opc connection by script (java/jython code)?

**URL:** <https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847>\
**Category:** Ignition\
**Created:** [December 1, 2015, 5:14pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847 "2015-12-01T17:14:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [December 1, 2015, 5:14pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/1 "2015-12-01T17:14:33Z")

</div>

I would like to disabled an opc-ua server connection by script.  
Can we achieve this with java/jython code ?

---

<div class="post-metadata">

**Author:** ![TimE](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TimE](https://forum.inductiveautomation.com/u/TimE)\
**Post date:** [June 10, 2016, 3:57pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/2 "2016-06-10T15:57:50Z")

</div>

Does anybody have an answer to this? I have a need for this also.  
Thanks.

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [June 15, 2016, 9:25pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/3 "2016-06-15T21:25:21Z")

</div>

Unfortunately there does not appear to be any way to do this currently. Closest you can get is being able to enable/disable devices on the Ignition OPC-UA server through scripting.

---

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [January 8, 2026, 3:49pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/4 "2026-01-08T15:49:45Z")

</div>

Over a decade later… is there now an option for this.

Only want the primary to have server enabled, if primary is down, would like to script or other option to enable the OPC-UA server on the secondary/fail over server.

---

<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:** [January 8, 2026, 3:58pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/5 "2026-01-08T15:58:32Z")

</div>

Looked at the docs yet?

---

<div class="post-metadata">

**Author:** ![Nol](https://avatars.discourse-cdn.com/v4/letter/n/8e8cbc/32.png) [@Nol](https://forum.inductiveautomation.com/u/Nol)\
**Post date:** [January 8, 2026, 8:02pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/6 "2026-01-08T20:02:49Z")

</div>

> [@ecujak](#):
>
> Only want the primary to have server enabled, if primary is down, would like to script or other option to enable the OPC-UA server on the secondary/fail over server.

> Standby Activity Level  
> Cold - The system connects to all OPC servers but does not subscribe to Tag values. The Ignition OPC UA server does not communicate with any device, but third party OPC UA servers may still have device connections. This allows the system to standby without putting additional load on the devices and network. Failover takes slightly longer, as Tags must be subscribed and initialized.

Do you actually want no connection at all or do you just not want the backup server to communicate and put load on the devices / network? Because a Cold spare is likely just the better route from what you're asking.

Otherwise you can read about the OPC functions in the manual:

> **[system.opcua | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-opcua)**
>
> OPC - UA Functions

---

<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:** [January 8, 2026, 8:19pm UTC](https://forum.inductiveautomation.com/t/disable-an-opc-connection-by-script-java-jython-code/10847/7 "2026-01-08T20:19:16Z")

</div>

That answer to the original question in this topic is: [system.opc.setServerEnabled | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-opc/system-opc-setServerEnabled)
