OPC UA won't connect? The 6 usual causes
Almost every "OPC UA client can't connect" case comes down to one of six things: the wrong endpoint, a blocked port, a security-mode mismatch, an untrusted certificate, bad credentials, or a node-access problem. Work down this list in order and you'll fix the large majority of failures.
1. Wrong endpoint URL
The endpoint must be exactly right, including scheme, host and port:
opc.tcp://192.168.10.20:4840 # correct
opc.tcp://plc-server:4840/UADiscovery
http://192.168.10.20:4840 # wrong scheme
192.168.10.20 # missing scheme/port
- Use the server's routable IP or resolvable hostname, not
localhostunless you're on the server. - Confirm the endpoint is reachable from the actual gateway location, not just an engineering laptop.
- Some servers advertise a hostname the client can't resolve: try the IP explicitly.
2. Port blocked / firewall
OPC UA binary usually runs on TCP 4840 (servers may differ). A TCP timeout or "connection refused" is almost always network/firewall:
# is the port open from where the client runs?
nc -vz 192.168.10.20 4840
# or
Test-NetConnection 192.168.10.20 -Port 4840 # PowerShell
If that fails: open the port on the server/OS firewall, check VLAN/routing, and confirm no NAT is rewriting the address the server advertises.
3. Security-mode mismatch
Client and server must agree on a security policy and mode (None, Sign, or Sign&Encrypt). If the client asks for a policy the server doesn't offer (or vice-versa), the handshake fails. List the server's endpoints first and pick a matching one.
4. Certificate not trusted (the most common)
With Sign or Sign&Encrypt, the client and server swap X.509 certificates and each must trust the other. A first connection typically fails because the client's certificate is sitting in the server's rejected folder (and/or vice-versa).
- Attempt the connection once (it will be rejected).
- On the server, move the client's certificate from
pki/rejectedtopki/trusted/certs. - On the client, trust the server's certificate when prompted.
- Reconnect.
Also check the certificate hasn't expired and that its application URI matches. Full detail: OPC UA security & certificates.
5. Bad or missing credentials
If the server requires user authentication, an anonymous connection will be refused. Confirm whether it expects anonymous, username/password, or a user certificate, and supply the right one.
6. Node access & expectations
You're connected but reads/writes fail? Confirm the node list is complete and stable, and clarify up front whether the requirement is read-only or the client is expected to write: write access is often restricted and must be enabled explicitly.
Quick checklist
| Symptom | Most likely cause |
|---|---|
| Connection refused / timeout | Port/firewall (#2) or wrong endpoint (#1) |
| "BadSecurityChecksFailed" / handshake error | Certificate trust (#4) or mode mismatch (#3) |
| "BadIdentityTokenRejected" | Credentials (#5) |
| Connect OK, read/write fails | Node access / permissions (#6) |
Which status code points to which cause?
Read the status code your client logs before changing anything. Each code below points to one of the six causes, so you can skip straight to the right fix. The links open our page for that code with its usual causes and checks.
| Status code | What it means in practice | Go to |
|---|---|---|
BadConnectionRejected | Nothing is listening on that host and port, or a firewall refused the connection | cause #2 |
BadTcpEndpointUrlInvalid | The endpoint URL, usually its path, is not one the server serves | cause #1 |
BadTcpMessageTypeInvalid | A peer received a transport message it does not accept; often a reverse-connect setup on one side only | cause #1 |
BadSecurityPolicyRejected | The server does not offer, or has disabled, the policy you asked for | cause #3 |
BadSecurityModeRejected | The server refuses the security mode you asked for on that endpoint | cause #3 |
BadCertificateUntrusted | The peer certificate is not in the trusted store | cause #4 |
BadCertificateTimeInvalid | The certificate has expired or is not yet valid, or a clock is wrong | cause #4 |
BadCertificateUriInvalid | The ApplicationUri does not match the URI in the certificate | cause #4 |
BadCertificateHostNameInvalid | The host you dialled is not in the server certificate | cause #4 |
BadSecurityChecksFailed | A generic security verification failure, most often a trust problem | cause #4 |
BadSecureChannelClosed | The secure channel was closed by a peer or the socket dropped | cause #2 |
BadIdentityTokenRejected | Wrong or refused user credentials | cause #5 |
BadUserAccessDenied | Authenticated, but the user may not do this on that node | cause #6 |
BadNotWritable | The node does not allow writes for this user | cause #6 |
BadNodeIdUnknown | The server has no such node; often a shifted namespace index | cause #6 |
Questions engineers ask
Why does UaExpert connect but my application does not?
The two clients are not configured the same way. Compare the endpoint, security policy, security mode and user token each one uses, then check the server's rejected certificate folder: your application has its own certificate, which the server must trust separately from UaExpert's.
Which port does OPC UA use?
TCP 4840 is the registered default port for opc.tcp, but many servers listen on another port. Read the port from the endpoint URL the server advertises or from its configuration, and open only that port between the client and the server.
How do I fix BadCertificateUntrusted?
Connect once so the certificate is rejected, then move it from the rejected folder to the trusted folder on the side that refused it. Check that the certificate is in date and that its ApplicationUri matches, then reconnect.
Can I just use SecurityMode None?
Only to isolate a fault on a test network. If the connection works with None and fails with Sign or SignAndEncrypt, the problem is security configuration or certificate trust. Put production back on SignAndEncrypt.
Get the free OPC UA connection checklist
A printable one-pager of these checks in order: keep it by the panel for the next commissioning.
Get the free checklist →Last updated 1 December 2026 · Educational resource.