---
title: Close Codes
description: The WebSocket close codes the exchange sends, what each means, and how to recover.
---

A close code ends the whole connection. Errors scoped to one command or one subscription arrive as `error` frames instead, and each operation page lists the codes it can send. Codes in the 1000 range are the standard WebSocket close codes; codes in the 4000 range are specific to the exchange.

| Code | Meaning |
| --- | --- |
| `1000` | Normal closure; reconnect only when another session is needed. |
| `1001` | Session lifetime or idle bound expired; reconnect and resubscribe. |
| `1002` | WebSocket protocol error; fix the client before reconnecting. |
| `1003` | Unsupported application data; send JSON text messages. |
| `1007` | Invalid UTF-8; fix the client before reconnecting. |
| `1008` | Repeated invalid or abusive input; back off and fix the client. |
| `1009` | Frame too large; send a smaller command. |
| `1011` | Unexpected server failure; reconnect with backoff and rebuild local state. |
| `1012` | Service restart, drain, or loss of a shared upstream source; reconnect with backoff and resubscribe. Events between the close and the new subscription are not replayed. |
| `1013` | Temporary service or admission failure; reconnect with backoff and rebuild local state. |
| `4001` | Authorization revoked; re-authenticate before reconnecting. |
| `4003` | Slow consumer or outbound memory bound; repair consumption, reconnect, and rebuild local state. This close frame is best effort, so an abnormal close is equivalent. |

After any close, reconnect with backoff, authenticate again, resubscribe, and rebuild state. See [Connecting](/reference/connecting?api=websocket).
