WebSocket 1012 Service Restart vs 1014 Bad Gateway
Both WebSocket 1012 (Service Restart) and 1014 (Bad Gateway) belong to the WebSocket Close Codes category. 1012 indicates that the server is terminating the connection because it is restarting. The client should reconnect after a brief delay. Meanwhile, 1014 means that the server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.
Description
The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
Quand vous le voyez
The server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.
Comment résoudre
Implement automatic reconnection with a short delay (1-5 seconds). This code signals that reconnecting is expected and should succeed once the server is back up.
Description
The server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.
Quand vous le voyez
A reverse proxy or API gateway tried to establish a WebSocket connection to a backend server but received an invalid or no response. The upstream server may be down or misconfigured.
Comment résoudre
Check the health of the upstream/backend WebSocket server. Verify the proxy configuration routes WebSocket upgrade requests correctly and that the backend is listening on the expected port.
Différences clés
WebSocket 1012: The server is terminating the connection because it is restarting. The client should reconnect after a brief delay.
WebSocket 1014: The server acting as a gateway or proxy received an invalid response from an upstream server it accessed while attempting to fulfill the request.
You encounter 1012 when the server is performing a planned restart — for example, during a deployment or configuration reload. The connection will be available again shortly.
You encounter 1014 when a reverse proxy or API gateway tried to establish a WebSocket connection to a backend server but received an invalid or no response. The upstream server may be down or misconfigured.
Quand utiliser lequel
For 1012 (Service Restart): Implement automatic reconnection with a short delay (1-5 seconds). This code signals that reconnecting is expected and should succeed once the server is back up. For 1014 (Bad Gateway): Check the health of the upstream/backend WebSocket server. Verify the proxy configuration routes WebSocket upgrade requests correctly and that the backend is listening on the expected port.