Nabu Casa: "Connection closed: Invalid auth" error

Hi all,

I have been using Home Assistant for 2 months now and I love it. Everything was working great (zigbee2mqtt, node-red, etc) until the moment that I wanted to use Nabu Casa cloud.

For some reason, I can connect to it, but the connections only last a few hours before I get the criptyc error message:

Logger: hass_nabucasa.iot
Source: /usr/local/lib/python3.9/site-packages/hass_nabucasa/
Connection closed: Invalid auth

After that, my Cloud connection status turns to “not connected”, despite my Remote Control status shows as connected. With that , I loose Alexa devices control, smartthings connection, etc.

I have contacted Nabu Casa support, but after a month I cannot figure out what is wrong with my connection. I have inactivated ipv6, energy management on the laptop and firewall, without fixing the problem.

If I go to the part of the code from the iot_base file that is returning the error message I see:

except client_exceptions.WSServerHandshakeError as err:
if err.status == 401:
disconnect_warn = “Invalid auth.”
self.close_requested = True
# Should we notify user?
self._logger.warning(“Unable to connect: %s”, err)

In other words it seems a 401 error, which suggest that I don’t have the authorization credentials for the connection. This is strange to me, since I could login without problems initially.

Can somebody please give me a suggestion of how to solve this problem?

I have been running Home Assistant in a old MacBook Pro (2009), in a virtual machine all installed as recommended.

Thank you for your attention!

Dose your virtual machine have the correct time?

Hi Tom_I,

Thank you for your answer. The time seems alright. If I go to the ssh shell in home assistant and use the comand “date” it gives the correct time, even when I get disconnected. Is this the correct way to verify if the virtual machine time is right?

I am running some tests to try to identify the source of the problem. I created a new virtual machine and restored from the backup everything but the system. Still got the problem, which suggests that the problems is not on my home assistant installation. Today I have created a new virtual machine and restored only the systems without any add-on (Mosquitto broker , zigbee2mqtt, etc). It is running connected without problems so far, but I still have to wait if it passes the disconnection time. If I still get disconnected, I will try restoring the backup into a new computer. If even on this case I get disconnected, them I will cancel my subscription to Nabu Casa and create a new account. Hopefully, I will get some answers with this experiment.

Suggestions are greatly appreciated!

I was having weird issues connecting as well and found that after going into the cloud section within HA and turning remote control off there, then flipping it back on, I’ve not had the issues. Seemingly simple thing to try that has worked for me so far.

Thank you Nameless for your suggestion. I have tried this before without success correcting the connection problem. This was something that Nabu Casa support has suggested. I also have tried deleting the .cloud folder, which didn’t solve the problem either.

Just an update in case somebody run in the same problem…

In my tests I have found that when I restore from a backup into a new computer, I don’t get this error anymore, using exactly the same settings for the virtual machine and the same backup. Therefore, my conclusion is that the error is something related to the old computer that I was using. It is an old computer that is not updated in terms of software (python, openssl, etc). I don’t have enough knowledgement to understand how the old software interferes with the virtual machine or the docker containers of HA. For now I will keep HA running in this new computer, but once I have time I will try to install Linux on this old computer and check if this solves this problem (I want to run HA from the laptop to have it running if energy supply to the house is cut by thieves)…

Thank you all for your suggestions!!