Sonos can't connect to HASS

Hi everyone,

Is anybody aware of any resolutions for Sonos suddenly stating that “the connection to HASSIP:8123 was lost”?

I’ve been trying to figure out what happened but recently I am in no way able to play any sounds through our hallway speaker anymore. We used it for the doorbell and alarm, but it recently stopped working.

Since it worked the following changes did happen:

  • Ubiquiti Cloud Key gen2 stopped working due to Hard drive issues. removed
  • Doorbell removed due to removal of the prior.
  • Moved network management to a Docker container.

From here on, no more sound came through so I started troubleshooting and trying different resolutions:
I Checked configuration on PFSense, LAN rules are set to:


1st rule: any source connecting to a specific LAN address on port 6443,80 or 22 is allowed to pass to that specific endpoint.
2nd rule: Any source connecting to HASS on port 1399 - 1500 is allowed to pass.
3rd rule: Any source connecting to any endpoint is allowed to pass.

These rules work top-down. 1st rule applies, it passes and stops. 1st rule doesn’t but second does, it passes and stops. 1st rule doesn’t apply nor does the second, pass and stop.
Please note this is for testing the environment and seeing if it’s stopped by my firewall or not.

None of these seem to apply. There are no denied logs for the Sonos speaker internally.

So instead I started looking into Unifi to see what could be the issue.
Initially I thought maybe it was the subnet (used multiple subnets previously). changed my whole setup to have everything on 1 subnet except for guest devices.
Didn’t make any difference.

Tried to change RSTP to STP. No difference.

Added the advertise_addr to my config, no difference:
image

Now the weirdest part (for me at least):
Hass is connected to the device. It found the device, it can control the device (play, pause, vol etc), and shows exactly what I told it to play from the app. I can hear the music playing.

However, when I run a script to play a sound from hass to it, it confirms.


But then when I open the app (because I hear nothing in this case) I get the error stating it can not connect.

Does anybody have an idea on what could still be causing this?
Anything I missed?

1 Like

Your HA host serves audio/TTS files on TCP port 8123. You need to make sure your Sonos devices can connect back to HA on that port. Media playing is totally separate from the rest of the controls.

Okay, I tried to add a specific rule between my Sonos IP and the HA IP to allow on port 8123.
It’s the same result.

Does Sonos go out (public internet), and then reconnect back in?

No, it will connect directly to the URL provided.

Since it seems like the errors you’re talking about are displayed in the Sonos app (meaning the play command reached the speaker), there are really only two likely possibilities:

  1. Some issue with DNS where the speaker cannot resolve your HA hostname.
  2. Some issue where the speaker cannot reach HA on the provided port.

Given there are many specific things that can cause the above, but perhaps start troubleshooting with those in mind.

Also, if you’ve moved to a single subnet, are you sure LAN traffic is even going through your pfsense firewall?

That’s interesting.
The errors are indeed in the Sonos app.

  1. DNS: Just double-checked AdGuard (runs on PFSense), but no logs referring to blocking it.
    Also tried to enable the avahi daemon to see if it makes any difference, but it doesn’t.

  2. I’m guessing this must be it, also because the DNS server (AdGuard) hasn’t changed since the removal of the Ubiquiti cloud key. I will check within Unifi if there’s anything in there that might be blocking it, but I can’t think of anything to be honest.

I use PFSense as the DHCP server, so I figured that might be causing some connection issues.
When I look at the firewall logs in there, there are a lot of logs. Including between internal devices.