Docker, nginx, n8n - needs proxy connection upgrade for websockets - else UX fails

Production webhooks working, test webhooks executed, but the UX did not trigger/update on “Listen for test events”. Frustrating.

In the browser console I found wss:// links - strange, since they should not be forwarded to client. Posts on n8n Community all have nginx config as…

proxy_set_header Connection '';

…so I wasn’t suspecting this one, until I came across the post by @Jon (thank you!) that mentioned…

proxy_set_header Connection 'upgrade';
proxy_set_header Upgrade $http_upgrade;

…which solved it. I asked Claude what proxy_set_header Connection ‘upgrade’; does and it all makes sense now…

When a client initiates a WebSocket connection, it sends an HTTP request with the Upgrade header, indicating that it wants to switch the protocol from HTTP to WebSocket. The server then responds with a successful upgrade response, and the connection is then upgraded to a WebSocket connection.

That was why I was getting wss:// links in the browser, they were not upgraded to WebSocket connection, so the /rest/push would fail.

  • nginx version: nginx/1.22.1
  • Docker version 26.0.0, build 2ae903e
  • n8n version 1.33.1
  • Debian 12.5
  • Kernel 6.1.0-18-amd64
  • Debian 6.1.76-1 (2024-02-01) x86_64