You point a charger at your CSMS, press connect, and nothing happens. No BootNotification, no CALLERROR, no frames at all. The connection failed before OCPP started, while the charger was still asking the CSMS to open a WebSocket. Every OCPP WebSocket connection error happens on the way to that one HTTP request or in its answer, and the answer usually tells you exactly what went wrong if you know how to read it.

This article reads it for you: what the connection request contains, how each failure shows itself (DNS, TLS, 400, 401, 404, 409, 429, 5xx, a refused subprotocol, a socket that opens and closes at once), and the fix for each. It also says which status codes an OCPP specification actually defines, and which are just how a particular CSMS was built.

If the socket opens and the CSMS answers your BootNotification with Rejected, you are past this stage: debugging a BootNotification rejection covers that. If you want to watch the failures as you read, Rey, the free browser-based virtual charge point, names each failure with a short code and a fix, and for an HTTP error also shows the status, the CSMS’s reason text and the exact address it dialled.

What the connection actually is

An OCPP-J connection starts as a plain HTTP GET that asks to be upgraded to a WebSocket. The charger is the client; the CSMS is the server. Four things in that request decide whether it succeeds.

The URL ends with the charge point ID. The CSMS gives you an endpoint URL, and the charger builds its connection URL by appending a / and its own identity, percent-encoded where needed (OCPP-J 1.6 section 3.1.1, and the same section of the 2.0.1 and 2.1 Part 4). With the endpoint wss://csms.example.com/ocpp and the identity CP001, the charger dials wss://csms.example.com/ocpp/CP001. An identity with a special character, RDAM|123, becomes RDAM%7C123 (OCPP 2.x allows no spaces in the identity; 1.6’s own example, RDAM 123, becomes RDAM%20123). OCPP 2.1 Part 4 caps the identity at 48 characters and forbids a colon in it, because the identity doubles as the Basic-auth username.

The subprotocol names the OCPP version. The charger lists the versions it speaks in the Sec-WebSocket-Protocol header, in order of preference, and the CSMS echoes back the one it picks:

OCPP versionSubprotocol
1.6ocpp1.6
2.0.1ocpp2.0.1
2.1ocpp2.1

Watch the spelling: ocpp2.0 is the older OCPP 2.0, not 2.0.1. And a version number in the URL path decides nothing: OCPP 2.1 Part 4, and 2.0.1 since its 2025 errata, say the version is chosen only by this negotiation.

Basic auth carries the credentials (security profiles 1 and 2). The header is Authorization: Basic followed by the base64 of username:password. The username is the charge point ID exactly as it appears in the URL. The password depends on the version:

VersionPasswordSource
1.6The AuthorizationKey configuration key: 16 to 20 bytes, written as 32 to 40 hexadecimal digitsOCPP 1.6 security whitepaper, A00.FR.205
2.0.1, 2.1The BasicAuthPassword variable: 16 characters up to the charger’s limit (40 to 64), sent as a UTF-8 string, not as bytes or base64A00.FR.205 and A00.FR.304

The 2.1 specification notes that its password encoding differs from 1.6. The 1.6 wording can be read two ways: put the decoded key bytes in the header, or the hex text as typed. If a 1.6 charger and CSMS read it differently, you get a 401 with a key that looks right.

wss:// means TLS first. With security profiles 2 and 3, the TLS handshake happens before the HTTP request is sent. The charger checks the CSMS certificate chain and that the certificate’s name matches the CSMS host name, and both sides use TLS 1.2 or above (A00.FR.308 to A00.FR.313 in 2.1; the 1.6 whitepaper has the same rules). Profile 3 adds a client certificate; the security profiles guide explains the trade-offs.

Put together, a 2.0.1 request on profile 2 looks like this:

GET /ocpp/CP001 HTTP/1.1
Host: csms.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
Sec-WebSocket-Protocol: ocpp2.0.1
Authorization: Basic Q1AwMDE6WHE3cEwydlI5bVdjNHRZaDhzS2Q=

And a CSMS that accepts it answers:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: ocpp2.0.1

Anything other than 101 with your subprotocol in it is a failed connection. The rest of this article is about the other answers.

Read the failure by where it stopped

A connection passes through five steps in order: find the host (DNS), reach the port (TCP), secure the channel (TLS), ask for the upgrade (HTTP), and agree a version (subprotocol). The error tells you which step failed, and each step has its own fix.

What you seeStepDefined by an OCPP spec?
Host not foundDNSNo
Connection refused, or a timeoutTCPNo
Certificate or handshake errorTLSThe checks are (A00.FR.3xx); the error text is your TLS library’s
400 or 426HTTP upgradeNo: HTTP and WebSocket (RFC 6455)
401 or 403Credentials401 appears in the OCPP Basic-auth sequence; 403 is CSMS behaviour
404Path or unknown IDYes: a CSMS SHOULD answer 404 for an unknown ID
409 or 423ID already connectedNo: CSMS behaviour
429Rate limitingNo: CSMS or proxy behaviour
5xxCSMS or its proxyNo
101 without your subprotocol, then a closeVersionYes: that is the specified refusal
Open, then closed at onceAfter the upgradePartly: depends on the reason

DNS, TCP and TLS: before HTTP

DNS. “Host not found” (ENOTFOUND in Node, getaddrinfo errors elsewhere) means the name doesn’t resolve. Check for typos, a hostname that only resolves inside a company network, and a scheme pasted twice (wss://wss://).

TCP. “Connection refused” means the host answered but nothing listens on that port. A timeout usually means a firewall drops the packets. wss:// defaults to port 443; if your CSMS listens on another port, it must be in the URL (wss://csms.example.com:8443/ocpp). OCPP lets a CSMS run each security profile on its own port (A00.FR.006 in 2.1), so the profile 3 port may not be the profile 2 port.

TLS. Three mistakes cover most TLS failures:

  • An incomplete certificate chain. The server sends its own certificate but not the intermediate. Browsers often repair this by fetching the intermediate themselves; embedded TLS stacks and most server-side clients don’t. Serve the full chain.
  • A name mismatch. The certificate is for csms.example.com and the charger dials an IP address, an internal name or a load balancer’s own name. Dial the name on the certificate.
  • A plain port behind wss://. Pointing wss:// at a port that speaks plain HTTP gives a handshake error such as “wrong version number”. The reverse, ws:// at a TLS port, gets a 400 or a closed connection.

Two more catch real chargers: a charger with no correct time can’t check a certificate’s validity dates (the 2.1 security section suggests NTP or setting the clock at install), and OCPP 2.1, and 2.0.1 since its 2025 errata, say a compliant station rejects a wildcard CSMS certificate unless AllowCSMSTLSWildcards is set to true.

400 and 426: the upgrade or the version

These come from HTTP and the WebSocket standard, not from OCPP. RFC 6455 gives 400 Bad Request as the example answer to an upgrade request a server can’t accept, and 426 Upgrade Required for a WebSocket version it doesn’t support. The version in a 426 is the WebSocket protocol version (Sec-WebSocket-Version: 13, which every current client sends), not the OCPP version. A CSMS that answers 426 or 400 to a subprotocol it doesn’t support is reusing the code. In practice you see them when:

  • a proxy or load balancer in front of the CSMS doesn’t forward the Upgrade and Connection headers, so the CSMS receives an ordinary GET;
  • you dialled the CSMS’s web or REST address instead of its OCPP endpoint;
  • the CSMS rejects the subprotocol with an HTTP error. That isn’t what OCPP-J asks for (see no agreed subprotocol below), but some servers do it.

Check that the address is the OCPP endpoint, that the version you offer is one the CSMS supports for this charger, and, if you run the CSMS, that the proxy passes WebSocket upgrades through.

401 and 403: credentials

The CSMS uses Basic auth and didn’t accept what you sent. The OCPP sequence diagrams for profiles 1 and 2 show 401 as the answer to a request without credentials, and A00.FR.207 says the CSMS checks that the ID and password match the Authorization header. A CSMS may answer 403 Forbidden instead, for a known charger whose password is wrong or which is disabled; that choice is the CSMS’s own.

Check, in this order:

  1. The username is the charge point ID, exactly. Same case, same characters as in the URL. A client that sets a different username fails even with the right password.
  2. The password is the current one. A CSMS that rotated it with SetVariables (2.0.1, 2.1) or ChangeConfiguration (1.6) expects the new one.
  3. On 1.6, the key’s form. Raw bytes or hex text: both sides must use the same one (see the table above).
  4. The security profile. A CSMS endpoint for profile 2 rejects a charger that sends no credentials, and A00.FR.002 says a CSMS terminates a connection made with a different profile than the one it uses.

A 401 is never a BootNotification problem. The BootNotification walkthrough makes the same point from the other side: if no boot frame ever left, the credential or the certificate is the problem, not the payload.

404: wrong path or unknown charge point ID

This is the one error status OCPP-J defines for the upgrade. OCPP-J 1.6 (section 3.2) and OCPP 2.1 Part 4 (section 3.3) say it in the same words: if the CSMS does not recognise the charge point identifier in the URL path, it SHOULD send an HTTP response with status 404 and abort the WebSocket connection. The 1.6 errata adds that the charger SHALL then retry with a back-off, so it doesn’t hammer the CSMS.

So a 404 has two causes:

  • The path is wrong. A missing segment (/ocpp), a different version path, or the ID added twice (below).
  • The ID isn’t registered. The CSMS knows the path but not this charger. Register the ID, or fix its spelling. Use the exact spelling the CSMS has on record. OCPP 2.x defines the identity as case-insensitive, but many CSMSs compare it exactly, so cp001 may not match CP001.

It is a SHOULD, not a SHALL. Some CSMSs accept the socket for any ID and answer the BootNotification with Rejected instead. Both are allowed; the 404 is just faster to diagnose.

The doubled ID and the trailing slash

The most common self-inflicted 404. Your CSMS’s portal shows a per-charger URL that already ends with the ID, wss://csms.example.com/ocpp/CP001. You paste it into a charger or tool that, as OCPP-J describes, appends the ID itself. It dials:

wss://csms.example.com/ocpp/CP001/CP001

The CSMS has no route for that, or reads the wrong segment as the ID, and answers 404. The fix is to enter only the endpoint, wss://csms.example.com/ocpp, and the ID in its own field. Charger firmware differs here: some append the ID, some expect the full URL. The charger’s manual says which.

A trailing slash does the same kind of damage. wss://csms.example.com/ocpp/ plus /CP001 gives …/ocpp//CP001, and a strict router doesn’t match the empty segment. Drop the trailing slash from the endpoint.

409 and 423: the ID is already connected

No OCPP specification assigns these codes. A CSMS that answers 409 Conflict or 423 Locked to an upgrade usually means: a charger with this ID already has an open connection. A second Rey tab, a colleague’s test, or the real charger in the field can all hold it.

CSMSs differ on what they do with a second connection for the same ID. Some refuse the newcomer with 409 or 423. Some accept the upgrade and then close it. Some accept the new one and drop the old one, which is friendly to a charger that reconnects before the CSMS noticed the old socket died, but means two clients with the same ID keep knocking each other off. If a charger flaps every few seconds, look for a twin.

The fix is the same in each case: one live connection per ID. Close the other one, or give your test client its own ID.

429: rate limiting

429 Too Many Requests comes from the CSMS or a proxy in front of it, not from OCPP. It means you reconnected too often. Wait, and check that your client backs off between attempts: the 1.6 errata asks for a back-off after a 404, and the heartbeat and connection lifecycle guide covers back-off with jitter for every reconnect. A charger stuck in a fast loop of failed attempts often earns its 429 after the first, real error, so scroll back to that one.

5xx: the CSMS failed

A 500 means the CSMS hit an error while handling the upgrade. 502 Bad Gateway, 503 Service Unavailable and 504 Gateway Timeout usually come from the load balancer or proxy in front of it: the CSMS process is down, restarting, or too slow to answer. None of these are about your request, and none are OCPP codes.

Retry with a back-off. If it repeats, the answer is in the CSMS’s own logs, not in the charger’s. If the response body has text, read it: CSMSs and proxies often put the reason there.

No agreed subprotocol

OCPP-J is explicit about this case. If the CSMS supports none of the offered versions, it MUST complete the WebSocket handshake with a response that has no Sec-WebSocket-Protocol header, and then immediately close the connection (OCPP-J 1.6 section 3.2; 2.1 Part 4 section 3.3). So the refusal is a 101 with the header missing, not an HTTP error.

A careful client treats a 101 without the header, or with a version it didn’t offer, as a failure. A careless one reports “connected” and then “closed”, which looks like the next case. Either way the fix is to offer a version the CSMS speaks for this charger. A 1.6-only CSMS won’t take ocpp2.0.1, and a CSMS may enable versions per charger, not per server.

The socket opens, then closes at once

The upgrade succeeded, and within a second the connection is gone, often before the BootNotification gets an answer. The usual reasons:

  • No common version, with a client that didn’t check the subprotocol (above).
  • The ID is already connected, on a CSMS that accepts the second socket and then closes it, or closes the first.
  • A security profile mismatch (A00.FR.002), or credentials a CSMS checks only after the upgrade.
  • An idle or proxy timeout that is far too short, if it happens a fixed time after connecting.

The WebSocket close code helps when there is one. 1002 is a protocol error, 1008 a policy violation, 1011 a server error (all from RFC 6455). 1006 is never sent by the other side: your client reports it when the connection ended without a close frame, which points at a proxy, a crash or the network. Beyond that, only the CSMS logs say why.

See it in Rey

Rey runs the same handshake in your browser. Choose My CSMS, enter your CSMS address and a charge point ID, add the Basic-auth password if your CSMS uses one, pick OCPP 1.6, 2.0.1 or 2.1, and press Connect. Rey offers exactly one subprotocol, for the version you picked.

When the connection fails, the CSMS card shows a short code and a plain-language message with a button for the fix:

  • An HTTP error (http_error) shows the status and its reason phrase, the text your CSMS put in the response, a fix for that status and the exact address Rey dialled. For a 404 it tells you to check the path and that the ID is registered; for 409 or 423, that the ID is probably already connected, with a Use a unique ID & retry button; for 400 or 426, to check the OCPP version and the path; for 429, to wait a minute; for a 5xx, that the CSMS failed on its side and its logs say why.
  • A refused password (auth) shows the 401 or 403 and the CSMS’s text, with a button to re-enter the password.
  • The other steps have their own codes: dns, connection_refused, timeout and tls. A CSMS that drops the connection during the handshake, or answers without a subprotocol, shows closed_by_csms. If the socket opens and the CSMS closes it afterwards, the log shows Connection closed instead.

Each failure also has an Explain button. It opens a short page with the failure’s stable Rey code (dns is REY-CONN-004, auth is REY-CONN-005), the side that most likely caused it, the likely causes and the steps to check. The codes stay the same from one Rey version to the next, so you can put them in a ticket.

Rey's My CSMS card after a failed connection to wss://csms.example.invalid/ocpp: the code dns, the message that Rey couldn't find csms.example.invalid, and the Check the address and Explain buttons.

Rey avoids the doubled-ID mistake: it ignores a trailing slash, and if you paste a per-charger URL that already ends with your charge point ID, it doesn’t add the ID again. The log says it dropped it and shows the address it dials. On any other 404, the dialled address on the card is the first thing to compare with what your CSMS expects.

Two limits. Rey only reaches public wss:// addresses: not ws://, localhost, a VPN or an office network. And it sends the password as UTF-8 text on every version, so a 1.6 CSMS that expects the key as raw bytes may refuse it. The handbook’s Connect section lists every code and its fix.

Once the socket opens, the rest of the setup is in connecting a virtual charge point to your CSMS, and errors inside the conversation, the CALLERROR codes, are in common OCPP errors explained.

The honest summary

A WebSocket that won’t open is almost never an OCPP problem. It is a URL, a certificate, a credential or a duplicate ID, and the CSMS usually says which, in an HTTP status that most tools throw away. The single most useful habit is to log three things on every failed attempt: the full address you dialled, the status code, and the response body.

Only one error code in this article has a meaning written into OCPP: 404 for an unknown charger. The other specified answer is a 101 without a subprotocol, which is how OCPP refuses a version. Everything else is HTTP, the WebSocket standard, or a choice the CSMS’s authors made. So when a code surprises you, read your CSMS’s documentation before the OCPP specification, because that is where its meaning was decided.