Error Codes Wiki

WebSocket 1006 Abnormal Closure — What It Means & How to Fix It

Errorapi errors

About WebSocket 1006 Abnormal Closure

Fix WebSocket close code 1006 indicating the connection was closed abnormally without a proper close frame exchange. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: WebSocket close code 1006 indicates the connection was lost without a proper close handshake. This code is never sent in a close frame — it is generated locally when the connection drops unexpectedly. Common in mobile applications, unstable networks, and when servers crash mid-connection. The browser's WebSocket API reports 1006 when it cannot determine why the connection closed. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Network interruption (Wi-Fi dropout, cellular handoff) breaking the TCP connection. Server process crashed or was killed while the WebSocket connection was active. Proxy or load balancer terminated the connection due to idle timeout. TLS/SSL certificate issue causing the connection to be dropped mid-session. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Implement automatic reconnection with exponential backoff in your WebSocket client. Add heartbeat/ping-pong messages to detect dead connections before the close event fires. Configure proxy and load balancer WebSocket timeouts to be longer than the heartbeat interval. Check server-side logs for crashes or restarts that correlate with 1006 close events. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Why can't I see a reason for the 1006 close?

Close code 1006 is reserved and never sent over the wire. The browser generates it locally when the connection drops without a proper close frame. There is no reason phrase available.

Overview

Fix WebSocket close code 1006 indicating the connection was closed abnormally without a proper close frame exchange.

Key Details

  • WebSocket close code 1006 indicates the connection was lost without a proper close handshake
  • This code is never sent in a close frame — it is generated locally when the connection drops unexpectedly
  • Common in mobile applications, unstable networks, and when servers crash mid-connection
  • The browser's WebSocket API reports 1006 when it cannot determine why the connection closed

Common Causes

  • Network interruption (Wi-Fi dropout, cellular handoff) breaking the TCP connection
  • Server process crashed or was killed while the WebSocket connection was active
  • Proxy or load balancer terminated the connection due to idle timeout
  • TLS/SSL certificate issue causing the connection to be dropped mid-session

Steps

  1. 1Implement automatic reconnection with exponential backoff in your WebSocket client
  2. 2Add heartbeat/ping-pong messages to detect dead connections before the close event fires
  3. 3Configure proxy and load balancer WebSocket timeouts to be longer than the heartbeat interval
  4. 4Check server-side logs for crashes or restarts that correlate with 1006 close events

Tags

websocket1006abnormal-closureconnection-lostreconnect

More in Api Errors

Frequently Asked Questions

Close code 1006 is reserved and never sent over the wire. The browser generates it locally when the connection drops without a proper close frame. There is no reason phrase available.