"Login attempt or request with invalid authentication" when trying to access remotely

I set up my Home Assistant VM in Proxmox together with an Nginx Reverse Proxy (that one is running in a separate container with the IP Accessing the login page remotely works with no issues, entering the 2FA code works as well, but then I’m getting the “Unable to connect to Home Assistant” error screen.

The log gives me the following warning:

Login attempt or request with invalid authentication from [Public IP of device I tried logging in with]

This is what my configuration.yaml looks like:

    use_x_forwarded_for: true

Thanks in advance for your help!


Was able to fix it. In the corresponding proxy configuration for Nginx you need to add

            proxy_set_header    Upgrade     $http_upgrade;
            proxy_set_header    Connection  "upgrade";

to the “location” tag


Hi @dge301 , i used your two lines in previus post in my Nginx proxy manager beacuse i had a similar problem, a lot of logins attempts, until now, it is seem a solution, thanks!

1 Like

Thanks @dge301 I was looking for that solution!

I’m having the same problem but the above solution didn’t fix the issue. I notice there is a note at the bottom of that custom config page that suggests that set_header won’t work if inputted here?

I did as the note suggested:

But the issue still persists. Sigh.


Same issue here. My Android companion app doesn’t work outside of local LAN. However geo tracking does work (so there is some connection to HA).

Anybody already found how to solve this?

Same config, same issue. Works fine if I use the external URL in a browser (request authentication, and loggin in works fine) but fails with the app.
It seems the app doesn’t request authentication.
Internally I use a trusted network value, so no authentication asked, and the app works fine.

i fixed this by logging out of the app. Disabling wifi so i was sure i was not accessing locally. Then entered the URL i use for HA (so no auto-detect). And login.

After this everything is working for local and remote through app.

1 Like

For me it work went i set the Connection header like this.

proxy_set_header    Upgrade     $http_upgrade;
proxy_set_header    Connection  $connection_upgrade;
1 Like

Could you help me with a print screen please? thanks!

had similar problem and did it as you mentioned and it worked :slight_smile:

For me the solution was to enable Websockets support in the proxy host settings in NGINX.


I found the soultion on reddit by iEatSponge:

This took me an hour to fix. I’m running home assistant in a docker container with nginx proxy manager in a separate container. I had everything set up properly, except I needed to check “Enable Webhooks Support” for my proxy host in nginx.

You don’t need to add the custom configuration. Hope it works for you


proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;

to nginx under location worked for me

My solution:

  1. Enable WebSockets in reverse proxy.
  2. Clear browser cache (important!)
  3. Login again


Thank you! That was the right solution for me.
NGINX running on opnSense Firewall, and HA exposed to the Internet via that.

This did it for me! Thanks

I don’t have Nginx or duckdns addon and I am getting this error when I’m accessing from my Android app outside of my LAN while connected to Wireguard VPN. Why do I need a certificate if I’m accessing http localhost:8123 URL? I also have a nabu casa URL which should take care of the certificate if I’m not connected to Wireguard. Is there a way to whitelist the wireguard public IP?

How did you configure this in the opnsense nginx? Where is the setting for websockets?