Tool
WebSocket Close Code Lookup
Look up WebSocket close codes, their meanings, and recovery actions for production debugging. Filter by category or search by code, name, or symptom.
WebSocket close codes are 16-bit unsigned integers sent in close frames. Codes 1000–1015 are standard protocol codes. Codes 3000–3999 are for applications. Codes 4000–4999 are for private services.
The most common production issue is code 1006 (Abnormal Closure), which typically means a network issue, timeout, or load balancer killed the connection.
Showing 20 of 20 codes
| Code | Name | Meaning | Recovery | Copy |
|---|---|---|---|---|
| 1000Normal | Normal Closure | The connection closed cleanly. Both sides agreed to close. | No action needed. This is expected behavior. | |
| 1001Normal | Going Away | Server is shutting down or browser navigated away. | Reconnect after a short delay. Check if server is undergoing maintenance. | |
| 1002Protocol | Protocol Error | Endpoint received malformed data that violates the WebSocket protocol. | Log the frame data. Check your message serialization and framing logic. | |
| 1003Protocol | Unsupported Data | Endpoint received data type it cannot accept (e.g., binary when only text expected). | Verify message encoding matches what the server expects (text vs binary). | |
| 1005Error | No Status Received | Connection closed without sending a close frame. | Treat as unexpected disconnect. Implement reconnection with exponential backoff. | |
| 1006Error | Abnormal Closure | Connection closed abruptly. No close frame was sent. | This is the most common production close code. Implement reconnection with backoff + jitter. Check network stability, firewalls, and load balancer timeouts. | |
| 1007Protocol | Invalid Frame Payload Data | Received data that doesn't match the expected format (e.g., invalid UTF-8). | Validate message encoding before sending. Add UTF-8 validation on your message producer. | |
| 1008Error | Policy Violation | Connection closed due to policy violation (message too large, forbidden content). | Check message size limits. Reduce payload size or implement message chunking. | |
| 1009Protocol | Message Too Big | Received frame exceeds the maximum allowed size. | Split large messages into chunks. Increase max frame size on server config. | |
| 1010Protocol | Missing Extension | Client expected server to negotiate an extension that server did not. | Review WebSocket extension negotiation. Disable unsupported extensions on client. | |
| 1011Error | Internal Error | Server encountered an unexpected condition that prevented it from fulfilling the request. | Check server logs for unhandled exceptions. Add health checks and graceful error handling. | |
| 1012Normal | Service Restart | Server is restarting. | Implement reconnection with backoff. Check if server has a maintenance window. | |
| 1013Error | Try Again Later | Server is temporarily overloaded. | Implement reconnection with exponential backoff + jitter. Reduce connection frequency. | |
| 1014Error | Bad Gateway | Server acting as gateway received an invalid response from upstream. | Check upstream service health. Implement circuit breaker for upstream calls. | |
| 1015Error | TLS Handshake Failed | TLS negotiation failed (can't be used from JavaScript — client-side only). | Verify SSL/TLS certificates. Check cipher suite compatibility. | |
| 3000Application | Application Reserved Start | Start of application-level close code range (3000-3999). | Consult your application's documentation for custom close code meanings. | |
| 4000Application | Application Reserved Start (Service) | Start of service-level close code range (4000-4999). | Consult your service's documentation for private use close codes. | |
| 4001Application | Auth Expired | Authentication token or session expired. | Refresh authentication token and reconnect. Implement token refresh before expiry. | |
| 4002Application | Rate Limited | Client exceeded allowed connection rate. | Implement connection rate limiting on client side. Back off before reconnecting. | |
| 4003Application | Unauthorized | Client credentials are invalid or missing. | Check API keys, tokens, and authentication headers in the connection request. |
Frequently asked questions
What is WebSocket close code 1006?
Code 1006 (Abnormal Closure) means the connection closed without sending a close frame. This is the most common production issue. It typically indicates a network problem, proxy timeout, load balancer killing idle connections, or a server crash. Implement reconnection with exponential backoff + jitter.
How do I fix WebSocket close code 1006?
Fix 1006 by: (1) implementing automatic reconnection with backoff, (2) sending periodic heartbeat/ping frames to keep the connection alive, (3) checking load balancer timeout settings, (4) adding WebSocket health monitoring with alerts, and (5) verifying firewall/proxy settings don't drop long-lived connections.
What is the difference between close code 1000 and 1001?
Code 1000 (Normal Closure) means both sides agreed to close the connection cleanly — no action needed. Code 1001 (Going Away) means the server is shutting down or the browser navigated away. For 1001, reconnect after a short delay and check if the server is undergoing maintenance.
Which WebSocket close codes require reconnection?
Codes requiring reconnection: 1001 (Going Away), 1005 (No Status), 1006 (Abnormal Closure), 1011 (Internal Error), 1012 (Service Restart), 1013 (Try Again Later), 1014 (Bad Gateway), and any application-range codes (4000-4999) indicating auth expiry or rate limiting.