WebSocket close codes
Type the code from your close event. You get what it means, which document defines it, and what usually causes it.
Everything runs in your browser. Nothing you type and no file you open is sent to a server.
Spec: RFC 6455 § 7.4IANA WebSocket Close Code Number Registry
Any number. Close codes run from 1000 to 4999.
Every code from 1000 to 1015
| Code | Name | What it means | On the wire |
|---|---|---|---|
| 1000 | Normal Closure | The connection closed as intended. Both sides were done. | yes |
| 1001 | Going Away | One side is shutting down: the page is unloading, or the server is stopping. | yes |
| 1002 | Protocol Error | A frame broke the WebSocket protocol. The stream can no longer be read reliably, so the connection closes. | yes |
| 1003 | Unsupported Data | The side that closed understands the data type but does not accept it. A text-only server got a binary message, for example. | yes |
| 1004 | Reserved | Reserved, with no meaning assigned. Old drafts used it for «frame too large», and 1009 does that job now. | no |
| 1005 | No Status Received | A Close frame arrived, but it carried no status code. The API reports 1005 instead of leaving the field empty. | no |
| 1006 | Abnormal Closure | No Close frame arrived and the connection just went away. The code says nothing about the cause. | no |
| 1007 | Invalid Frame Payload Data | The payload does not match the frame type. Most often a text frame that is not valid UTF‑8. | yes |
| 1008 | Policy Violation | The message broke an application rule and no more exact code fits. It is the generic «you cannot do that». | yes |
| 1009 | Message Too Big | The message is bigger than the other side will process. | yes |
| 1010 | Mandatory Extension | The client asked for an extension, the server did not negotiate it, so the client closes. Only clients send this code, because a server fails the handshake instead. | yes |
| 1011 | Internal Error | The server hit an unexpected condition and cannot finish the request. It is the WebSocket version of a 500. | yes |
| 1012 | Service Restart | The server is restarting. Reconnect, but wait a bit first. | yes |
| 1013 | Try Again Later | The server cannot take the connection right now. It is overloaded or throttling. | yes |
| 1014 | Bad Gateway | A gateway or a proxy got an invalid response from the server behind it. It is the WebSocket version of a 502. | yes |
| 1015 | TLS Handshake | The TLS handshake failed. Browsers never use this code: they report 1006 instead. | no |
The ranges
- 1000–2999
- Belongs to the protocol and the IANA registry. Nothing of yours goes here, and a browser refuses to send any of it except 1000.
- 3000–3999
- Libraries, frameworks and apps, registered with IANA. Look the meaning up in the docs of whatever sent the code.
- 4000–4999
- Private use. You define the meaning and register nothing.
Want to see more?
View in Solpuga