Nginx setup WebSocket connection error with a subdomain name


  • I’m trying to host my streamlit service on a subdomain name of my domain on my Ubuntu server using Nginx via http not https.
  • No docker is involved.
  • I got “WebsocketConnection WebSocket onerror” and “WebSocket connection to ‘wss://’ failed: (anonymous) @ main.ac67fab5.js:2” from Console
  • I tried all the solutions in the forum with keyword “Nginx” but non worked so far.
  • My streamlit service work nicely on the port 12345 of my server, but doesn’t work on my domain set up with Nginx.
  • Thanks in advance for any suggestions!


My nginx.conf:

        server {
                listen 80;
                location / {
                location /streamlit {
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "upgrade";

Console output:

Source of error

maybe it’s because you are trying to upgrade the connection? It looks like it remains HTTP the whole time and never goes to HTTPS – just spitballing

My setup for elastic beanstalk has a few more arguments, not sure whether they are actually needed or not:

    location / {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_read_timeout 600;

I have the same problem, have you solved it?

exactly same problem for me…anyone solved it?