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

CodeNameWhat it meansOn the wire
1000Normal ClosureThe connection closed as intended. Both sides were done.yes
1001Going AwayOne side is shutting down: the page is unloading, or the server is stopping.yes
1002Protocol ErrorA frame broke the WebSocket protocol. The stream can no longer be read reliably, so the connection closes.yes
1003Unsupported DataThe side that closed understands the data type but does not accept it. A text-only server got a binary message, for example.yes
1004ReservedReserved, with no meaning assigned. Old drafts used it for «frame too large», and 1009 does that job now.no
1005No Status ReceivedA Close frame arrived, but it carried no status code. The API reports 1005 instead of leaving the field empty.no
1006Abnormal ClosureNo Close frame arrived and the connection just went away. The code says nothing about the cause.no
1007Invalid Frame Payload DataThe payload does not match the frame type. Most often a text frame that is not valid UTF‑8.yes
1008Policy ViolationThe message broke an application rule and no more exact code fits. It is the generic «you cannot do that».yes
1009Message Too BigThe message is bigger than the other side will process.yes
1010Mandatory ExtensionThe 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
1011Internal ErrorThe server hit an unexpected condition and cannot finish the request. It is the WebSocket version of a 500.yes
1012Service RestartThe server is restarting. Reconnect, but wait a bit first.yes
1013Try Again LaterThe server cannot take the connection right now. It is overloaded or throttling.yes
1014Bad GatewayA gateway or a proxy got an invalid response from the server behind it. It is the WebSocket version of a 502.yes
1015TLS HandshakeThe 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.

The long version: WebSocket closed with code 1006

Want to see more?

View in Solpuga