Websockets Error 500 in traefik logs

Since yesterday basicly, my HA doesn’t work remotely anymore.
Yesterday I swiched over from an old YAML maintained Lovelace to a webbased/maintained frontend.

My Home assistant runs on a Yellow, My Traefik proxy runs on my NAS.
When I connect locally to http://yellow-ip:8123, everything works fine, but when I go to https://my.external.url and login, I get the message: “unable to connect” with the countdown counter.
When I look in my traefik logs, I see a lot of error 500 from HA for RequestPath /api/websocket:

{"ClientAddr":"172.10.0.1:44404","ClientHost":"172.10.0.1","ClientPort":"44404","ClientUsername":"-","DownstreamContentSize":21,"DownstreamStatus":500,"Duration":859943,"OriginContentSize":21,"OriginDuration":371773,"OriginStatus":500,"Overhead":488170,"RequestAddr":"my.external.url","RequestContentSize":0,"RequestCount":4801,"RequestHost":"my.external.url","RequestMethod":"CONNECT","RequestPath":"/api/websocket","RequestPort":"-","RequestProtocol":"HTTP/2.0","RequestScheme":"https","RetryAttempts":0,"RouterName":"homeassistant-tls@file","ServiceAddr":"yellow-ip:8123","ServiceName":"homeassistant@file","ServiceURL":"http://yellow-ip:8123","SpanId":"0000000000000000","StartLocal":"2025-01-07T18:03:20.75412082+01:00","StartUTC":"2025-01-07T17:03:20.75412082Z","TLSCipher":"TLS_AES_128_GCM_SHA256","TLSVersion":"1.3","TraceId":"00000000000000000000000000000000","entryPointName":"external-https","level":"info","msg":"","request_User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36","time":"2025-01-07T18:03:20+01:00"}

My rules file for traefik is as followed:

http:
  routers:
    homeassistant-tls:
      tls:
        certresolver: certresolver
      entryPoints:
        - external-https
      service: homeassistant
      rule: Host(`my.external.url`)

  services:
    homeassistant:
      loadBalancer:
        servers:
          - url: "http://yellow-ip:8123"

I have added my proxy to the trusted_proxies in my configuration.yaml

In the browser console I only see the error "WebSocket connection to ‘wss://my.external.url/api/websocket’ failed: "

I’m a bit puzzled here. Perhaps it is the translation that Traefik does from wss to http? I can’t find anything online regarding (Traefik) reverse-proxies and websocket access for Home-Assistant. I there anyone here that has an idea?

1 Like

Same issue here. Works if I go directly to the IP but not behind Traefik.

It doesn’t seem to have modified the Trusted_proxies setting in configuration.yaml.

Good that you mentioned it, I have set the trusted_proxies setting in my configuration.yaml. I’ll update my startpost with that information.

I found the issue. It’s a traefik bug.

Downgrade to 3.2.3 until they get the new 3.3.1 release pushed to Docker hub.

2 Likes

You’re my hero of the day! thanks!