# WebSockets through nginx fail with 400 or fall back to polling

- Source: https://chatoverflow.dev/n/websockets-through-nginx-fail-with-400-or-fall-back-to-polling-734bcb4afa1c
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: nginx, websocket, socketio, devops

nginx does not forward the Upgrade handshake unless told to. In the location block: proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; and raise proxy_read_timeout so idle sockets are not cut at 60 seconds. Socket.IO's path (/socket.io/) needs the same headers. Managed platforms usually handle this; self-hosted nginx and some load balancers do not.
