LDS Purpose and When a PLC Needs One
A Local Discovery Server (LDS) is intended to run locally — on the same physical box as the OPC UA servers it catalogs. The design assumption is that one PC can host several UA servers, and a single LDS maintains the list of all servers registered on that machine. Clients query the LDS to discover every server endpoint without probing multiple ports.
A PLC normally runs exactly one UA server: the PLC's own CODESYS UA server. With only one server on the device, there is nothing for an LDS to aggregate, so no LDS is required. The single PLC server should instead listen directly on port 4840 — the same port the LDS would otherwise occupy — so clients connect to it without a discovery hop.
Port 4840 Assignment
Port 4840 is the standard OPC UA endpoint port, and on a multi-server PC the LDS claims it as the well-known discovery address while individual servers use other ports. On a PLC, inverting that convention is correct: the PLC UA server takes 4840 directly because it is the only server present.
| Host scenario | Who owns port 4840 | Discovery path |
|---|---|---|
| PC with multiple UA servers | Local LDS | Client queries LDS for registered server list |
| PLC with one CODESYS UA server | The PLC UA server itself | Client connects to 4840 directly; no LDS |
| Site-wide registration | GDS (Global Discovery Server) | Servers register remotely at the GDS |
Certificate Trust for LDS Registration
To register at an LDS, the UA server acts as an OPC UA client toward the LDS. Registration therefore requires a mutual trust relationship: the server must trust the LDS certificate, and the LDS must trust the server certificate. The procedure is to exchange certificates between the two applications and place each certificate in the other's trusted store; only after both directions of trust are established can the server complete registration.
Remote LDS, GDS, and CODESYS-Specific Capability
Some installations register a PLC server at an LDS running on a different PC in the network. This remote registration works but is not the intended LDS role — site-wide, cross-machine registration is the job of a Global Discovery Server (GDS). If the architecture requires network-level discovery, plan for a GDS rather than stretching a remote LDS beyond its local purpose.
UA servers built on common commercial SDKs support LDS registration out of the box through basic configuration settings. Whether the CODESYS UA server implements this registration function is not confirmed here, because it was not built on those SDKs. Verify registration support and the exact procedure in the CODESYS UA Server product manual, and confirm open questions with CODESYS support before designing the discovery architecture around it.
FAQ
Does a CODESYS PLC need an OPC UA Local Discovery Server?
No. A PLC typically runs only one UA server — the CODESYS PLC UA server — so there is no list of servers for an LDS to maintain. Run the PLC server directly on port 4840.
What is required for a UA server to register at an LDS?
The server acts as a client toward the LDS and needs mutual certificate trust: exchange certificates, trust the LDS certificate on the server, and trust the server certificate on the LDS. Registration only succeeds after both trust directions are configured.
Can a PLC register at an LDS on a different PC?
Remote registration is possible but not the intended use of an LDS; network-wide registration is the role of a Global Discovery Server (GDS). Confirm whether the CODESYS UA server implements registration at all with CODESYS support, since it is not based on the common SDKs that provide it out of the box.