Thanks all for the help. Cloudflare states that websockets are supported by default without any configuration changes. I’m fairly confident the problem is with how my nginx is working. I have Googled and tried some other solutions to get nginx to support websockets but nothing has worked. Unfortunately I don’t think this is worth the time and effort anymore. I have spent many hours so far and haven’t made much progress. I’m just going to go back to using duckdns to access home assistant.
Don’t give up! I’m having the same issue… It’s been working fine for AGES. Did something break during a recent upgrade?
Found my problem. My Lets Encrypt SSL Certs expired…months ago apparently and things just kept working until my system went offline for most of a day. Fixed my certs and it started working again.
My situation is similar: I am trying to access my local HA instance that is already accessible from outside the network using a duckdns domain using the Nginx Proxy Manager on a rented server. I am stuck with such a weird configuration because I don’t have a public ipv4 address.
I am getting the same errors that you described earlier. I found online, that setting
in Nginx is supposed to help with socket forwarding. I don’t know how to use it properly in NPM but maybe it helps you out or someone else has an idea?
I had exactly same problem and I’ve finally solved it by enabling WebSocket custom headers - $http_upgrade and $connection_upgrade - in reverse proxy (I’m using standard reverse proxy built in DSM, but I believe there is something similiar in Nginx Proxy Manager).
Hi! Good to see you have it working. Can you please share how to add those headers to Nginx Proxy Manager? I also keep getting the “Unable to connect (…)” error after switching from the HA add-on Nginx (which was working) to the Proxy Manager that I have running on another device.
Although I have been trying for hours to get everything working before I posted, ofcourse just after posting I found the solution. I missed the checkbox of Websockets support. It’s working!
Someone know how can I put this settings in the “Nginx Proxy Manager” please ?
I have same problem when I access from my work office PC (outside)
But it’s work when I use the mobile phone Android (outside)
In the Chrome console give me:
core.a0afd420.js:1 WebSocket connection to ‘wss://hass.xxxdomain.com/api/websocket’ failed:
(at my work office PC outside of my LAN)
I just found this thread after having the same issue. I am using Cloudflare and nginx proxy manager. To get it working, go to nginx proxy manager and open the proxy host settings for the home assistant proxy you have configured. You will see the option there for Websockets support. Enable that and you should be good to go.
Looking everywhere and found this thread! Having same problem but don’t know how to apply the WebSocket custom header on Nginx Proxy Manager.
Please if someone could guide us
To get it working, go to nginx proxy manager and open the proxy host settings for the home assistant proxy you have configured. You will see the option there for Websockets support. Enable that and you should be good to go.
Hi @barabasz
I am trying to include HA in my DSM reverse proxy with no luck so far. I would be grateful if you could provide some guidance.
Also, is DSM the best application, or do you recommend anything else?
Thanks in advance
I have similar problem but didn’t bother to look into it as I rarely need to access from outside the firewall. Finally today got a chance and got some insights from the posts above on proxy_set_header. To apply the two proxy_set_header rules in Nginx Reverse Proxy, add the following rules in Custom Location
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
I am having this same issue except its only occuring when using Firefox. Chrome and Edge both connect fine through my domain. I’ve tried adding the set header commands to the location but it has no affect when using Firefox. Any ideas why this is happening?
edit
To add to this, running Firefox in Troubleshooting Mode fixes it.
edit2
It was uBlock Origin that was causing it. I disabled it and it works now.