You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue: recv() failed (104: Connection reset by peer) while proxying/upgrading WebSocket in NGINX with Socket.IO #5370
We're encountering the following NGINX errors while using it as a reverse proxy to a Node.js server running Socket.IO. These errors occur during WebSocket connections.
We're encountering the following NGINX errors while using it as a reverse proxy to a Node.js server running Socket.IO. These errors occur during WebSocket connections.
The 104: Connection reset by peer errors from NGINX are normal when a client drops its connection (tab close, network switch, mobile sleep). NGINX logs them because it tries to forward data to an upstream that has already disconnected on the client side. The fact that Socket.IO server logs show no corresponding exceptions or disconnect events is the more interesting part — it means the server-side socket cleanup might not be propagating correctly through the proxy layer.
For debugging, try adding io.engine.on("connection_error", (err) => console.log("engine connection_error:", err)) and io.on("disconnect", (reason, socket) => console.log("disconnect:", reason, socket.id)) to see if the disconnect is reaching your app at all. You can also check netstat -anp | grep 8080 during the issue to see if there are sockets stuck in CLOSE_WAIT, which would confirm the server process isn"t cleaning up properly.
Also worth noting: your proxy_read_timeout of 75s might be too short for idle WebSocket connections. When there is no data flowing, NGINX will close the proxy connection after 75s of silence, generating exactly this error. Consider bumping it to something like 86400 for WebSocket connections, or use a separate location block for /socket.io/ with much longer timeouts.
Activity
expo20999-ship-it commentedon Oct 5, 2025
darrachequesne commentedon May 29, 2026
@Naveen-Mallow have you found the culprit?
AliMahmoudDev commentedon Jun 6, 2026
The
104: Connection reset by peererrors from NGINX are normal when a client drops its connection (tab close, network switch, mobile sleep). NGINX logs them because it tries to forward data to an upstream that has already disconnected on the client side. The fact that Socket.IO server logs show no corresponding exceptions or disconnect events is the more interesting part — it means the server-side socket cleanup might not be propagating correctly through the proxy layer.For debugging, try adding
io.engine.on("connection_error", (err) => console.log("engine connection_error:", err))andio.on("disconnect", (reason, socket) => console.log("disconnect:", reason, socket.id))to see if the disconnect is reaching your app at all. You can also checknetstat -anp | grep 8080during the issue to see if there are sockets stuck in CLOSE_WAIT, which would confirm the server process isn"t cleaning up properly.Also worth noting: your
proxy_read_timeoutof 75s might be too short for idle WebSocket connections. When there is no data flowing, NGINX will close the proxy connection after 75s of silence, generating exactly this error. Consider bumping it to something like 86400 for WebSocket connections, or use a separate location block for/socket.io/with much longer timeouts.