Answered

Plex on Sonos


I'm setting up Plex on my Sonos system but have noticed that there are some problem with this. By what I have read it looks like the Sonos system needs the source to come from the Internet. I will be posting on the Plex community and my Routers community form to resolve this issue.

Basically what happens is that you are able to look at your media files up to the point of playing them than you get an error that the file play the file as it is unavailable. I removed and added the service back and now it can’t even find any files.

What I’m after is finding out how Sonos communicates with Plex and if I need any special ports are required.

Cheers
icon

Best answer by MikeV 5 June 2017, 15:04

From what I have gathered in my setting up and use of Plex and Sonos is...

Browsing your music library really requires the Remote Access functionality of Plex to be enabled. Sonos communicates with Plex's own servers, which retrieve the needed library data from your Plex server and format it to be displayed on Sonos.

Playing music technically still needs the Remote Access function, but it relies on a router function called "Hairpin NAT" to keep your internet connection from being used. When you go to play music, Plex provides Sonos with your router's public IP address as the source. For routers that support Hairpin NAT, either internally or through an advanced setting, the router will realize that the connection from your Sonos speaker(s) is intended for your Plex server, and will route that connection back to the Plex server without ever touching the internet.

While many people have their Plex server on the same network as Sonos, Plex's use of the public IP address also allows you to access a remote Plex server to play music from it as well, like a remote family member's server if they're using the Plex Home functionality of Plex Pass.

Nothing more is needed than the port forward that Plex requires for regular remote access, so that should be easy.
View original

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

24 replies

Userlevel 7
Badge +21
From what I have gathered in my setting up and use of Plex and Sonos is...

Browsing your music library really requires the Remote Access functionality of Plex to be enabled. Sonos communicates with Plex's own servers, which retrieve the needed library data from your Plex server and format it to be displayed on Sonos.

Playing music technically still needs the Remote Access function, but it relies on a router function called "Hairpin NAT" to keep your internet connection from being used. When you go to play music, Plex provides Sonos with your router's public IP address as the source. For routers that support Hairpin NAT, either internally or through an advanced setting, the router will realize that the connection from your Sonos speaker(s) is intended for your Plex server, and will route that connection back to the Plex server without ever touching the internet.

While many people have their Plex server on the same network as Sonos, Plex's use of the public IP address also allows you to access a remote Plex server to play music from it as well, like a remote family member's server if they're using the Plex Home functionality of Plex Pass.

Nothing more is needed than the port forward that Plex requires for regular remote access, so that should be easy.
Hi Mike,
Thanks for your reply.
Yea that is what i gathered from all the information on the Sonos & Plex forms. Lucky for me I use a Sophos UTM which allows me when I NAT to change where the traffic is going to, change where the traffic came from and also change the port when it is redirecting as I don't have my Plex on the default port for security reasons.

It is up and running now and working great. Only issue I'm having now is that it is not displaying the covers. I read that the covers has to be embedded which I know I have.......

Cheers
This isn't working for me. I think the issue is on the Sonos side. My router is reasonably simple, but I've added port forwarding and I can use Plex from another device on my home network. I can browse the Plex library in the Sonos app, but it mostly refuses to play anything. Not sure what else to try.
Userlevel 7
Badge +21
This isn't working for me. I think the issue is on the Sonos side. My router is reasonably simple, but I've added port forwarding and I can use Plex from another device on my home network. I can browse the Plex library in the Sonos app, but it mostly refuses to play anything. Not sure what else to try.
The issue is in how Plex has implemented things. It's something some routers just aren't capable of supporting, unfortunately.

You can browse your Plex library because that's actually your Sonos device talking to Plex's cloud servers, which are retrieving info about your music library from your Plex server and formatting it for Sonos to understand. But when you go to play music, Plex's cloud server is telling your Sonos player to connect directly to your local Plex server... but not how you'd expect. It's telling Sonos to use your router's WAN address - not your Plex server's LAN address - to make that connection. And this is where the problem lies.

Sonos wants to make a connection to your Plex server on your LAN, but using your router's WAN address from inside your LAN. Some routers can figure this out. Some routers need a little help (and may have a setting that can be enabled). And some routers just don't get it (Why in the world would a device on the LAN be making a connection to another device on the LAN using the WAN IP address???).

But the likely reason Plex does what they do is because it also allows someone who is part of a Plex Home setup to access music on another family member's Plex server, which would use THEIR router's WAN address. And that's likely why they use WAN addresses instead of LAN addresses.

Whether Plex will do anything to fix this in the future remains to be seen. They seem to have abandoned the project immediately after it became available.
Hi there,

Thanks for the reply.

The reason I think it's not my router that's the issue is that I can play stuff through plex on another device on my home network.

Cheers though.
Userlevel 7
Badge +21
Right... but Plex apps on most other devices have another way of detecting Plex servers that Sonos doesn't. Plex servers "broadcast" their presence on the local network, and Plex apps on most other devices are able to see that broadcast and connect directly to the server using its LAN address, rather than the router's WAN address.
Right... but Plex apps on most other devices have another way of detecting Plex servers that Sonos doesn't. Plex servers "broadcast" their presence on the local network, and Plex apps on most other devices are able to see that broadcast and connect directly to the server using its LAN address, rather than the router's WAN address.

Ah yes. There's uPnP etc.
So how can I setup the port forwarding for my Sonos to work with Plex? I see my library in the Plex Sonos app but it says unable to connect when I try to play a song. I have the linksys smart WiFi router wrt1900ac
So was the above question ever answered? I have the same problem with Plex not connecting and playing to my Sonos play5... Help needed what is the difference between a LAN and WAN? some of us are just not that techy to understand. Most of us just want plug and play with all the techy stuff automatic.With two big service brands like Sonos and Plex they should make it easy for users to use their services without having the need for an IT degree. We just need it simple!
Hi Mike,
Thanks for your reply.
Yea that is what i gathered from all the information on the Sonos & Plex forms. Lucky for me I use a Sophos UTM which allows me when I NAT to change where the traffic is going to, change where the traffic came from and also change the port when it is redirecting as I don't have my Plex on the default port for security reasons.

It is up and running now and working great. Only issue I'm having now is that it is not displaying the covers. I read that the covers has to be embedded which I know I have.......

Cheers


Hi ilatimer,

I also an using Sophos UTM - the "provided free for home use" version for up to 50 connections! How can you pass that up?! I'd be interested in knowing exactly what you did to the UTM with regard to Sonos and the Plex Server. My config looks something like:

FiOS --> FiOS router (gateway) --> UTM NIC 1 --> UTM NIC 2 --> Internal Network
ext IP --> 10.1.20.1 --> 10.1.20.9 --> 10.1.10.9 --> 10.1.10.101 - 10.1.10.199

I have a ton of IT experience but am fairly new to the UTM, so any step-by-step detail you can provide would be great!!

Thanks
So some days have passed including Christmas since the question was asked and there still seem to be no answer on how to change or make the router settings connecting the wifi Sonos use the LAN address rather than the WAN when connecting to Plex, if that is what I understand the route of the problem really is of Sonos not playing the visible Plex library. If a knowledgeable techy member could perhaps explain in simple language how to change the router config or whatever settings need changing to make Sonos play the music, I and it seems several other members would be very grateful!

Before Christmas, I had several email chat conversations with Sonos support on this problem but no working solution was found, so even the experts seem baffled by this! So if anybody has got a working fix for this then they are up for a gold star!

I also have an even bigger anomaly with this situation and that is when my internet connection is going through my VPN the Sonos reads the Plex library and PLAYS the music too, also the artwork pictures is displayed, but only when connected through my VPN, so can anybody tell why this should be? And like others on here, the Plex libraries work fine through the Smart TV sound bar and other players devices, just the Sonos has the problem!
@joego - The simple answer is that Sonos looks to the [external] internet to play music. Since the Plex Server resides on the same internal network as the Sonos, it apparently can't handle this. The only way for Sonos to see/play Plex is to go out your internet connection, then essentially back in again to "see it" from the outside. This is typically called "hair-pinning" which describes the path. I assume when you connect your VPN, the router is somehow allowing this hair-pinning to occur since it sees it as a different path to the Plex Server - i.e. not on the same internal network. In some routers, you can adjust settings to allow hair-pinning, some not. It really depends and there are literally 1,000's of routers and configs out there.

There are a couple of solutions here - the easiest being to put a setting in the router that fools Sonos into thinking the music source is external. So for instance, if your Plex Server is 192.168.1.10 and your Sonos is 192.168.1.101, you would put an entry in your router (prob 192.168.1.1) telling it that whenever Plex is found on your external WAN address (open Google and type "IP address") return the 192.168.1.10. Sort of like "bouncing back" from the router instead of hair-pinning. Hope that makes sense if you're non-tech.

Of course, this doesn't solve the problem of how the Sonos would handle the different Plex Users as do they 100's of other devices. For example, I have my "adult" music collection under a separate folder, and thus library requiring a PIN. My Disney-friendly, kid lyric equivalent songs are in a different folder/library for general no-PIN access.
Userlevel 7
Badge +21
The issue depends on your router's ability to "hairpin" the connection request. Plex tells Sonos to access your Sonos server through your router's WAN address. Some routers/firewalls are smart enough to know that "Hey, there's a port forward that this connection wants to use, I'll send it back into the LAN"... some aren't. Joego, since you have TWO routers, it's the Verizon router that will need to support this "hairpinning", but your UTM needs to also allow the port in from the Verizon router to your Plex server.

I run pfSense as my main router/firewall... I don't have an ISP-provided gateway, just a cable modem (Comcast is my provider), so I don't have to deal with double NAT or a provider router. I've had no problem getting it to work, though I did have to enable a NAT proxy option in my port forward settings to get it to work right.
Thanks to both C-sunnedTech and MikeV for their detailed and considered reply. It seems to I am having to learn a whole new language! However, I do understand what you are saying about confusion and conflict on the internal network between the Sonos and the Plex and the need to get them to see each other through a different path. Apparently, my ISP supplied router is an ARRIS TG2492LG but I do not know it this supports hairpining or loopback or how to find out? I don't know if you are able to offer any insight or advice on how to config this router to enable hairpining or even if it is possible?

PS: Shouldn't Sonos be issuing a software update to solve this problem with their PLEX add-on?

Many thanks for your time and trouble for helping a complete novice -Joego
Userlevel 7
Badge +21
It's not Sonos' problem to fix. Plex is the one that writes the code that tells Sonos what to be playing. Plex could make a change such that when it gets Sonos requests from the same WAN address that the Plex server is also originating from, it could instead return the internal LAN address to Sonos, allowing a direct, within-the-network connection between the Sonos speaker and the Plex server... I'm sure there are other possibilities too, but it's on Plex to fix them. Unfortunately, they've shown 0 effort towards their Sonos support from the day it was released. It's been months since a Plex employee posted in the Sonos area in their own forums, and the only time a developer posted in it was release day.

As far as if your router supports it... some people have found that simply manually creating the port forward, rather than letting the Plex server do it through UPnP, has made it work for them. I mentioned hairpin NAT or NAT proxying... some routers might just have a setting that says "Allow connections to WAN address from the LAN"...
MikeV, i'm basically following your explanation of the problem - Plex is asking Sonos to access LAN server from WAN address - but then you mention that one solution is to port forward. This is where I need assistance. Please layout the port forward configuration.
1) For which device on my network do I setup the port forward rule (the individual sonos device that I'm asking to access Plex?
2) What external port do I set for the port forward (is this the same external port that Plex uses)?
3) What internal port do I set for the port forward (is this the same internal port that Plex uses)?
Thanks in advance.
Userlevel 7
Badge +21
1. You set up the port forward on your router to point to your Plex server. It only needs to be set up for the server.
2. The external port can be anything. In my case, I made it the same as what Plex uses. If you make it different, you'll need to specify this number in the Plex server's remote access settings.
3. The internal port needs to be the port that the Plex server is listening on, 32400 by default.
Thanks MikeV - that worked for me! Thanks for the education.
Oh, honestly! Chromecast Audio (an excellent product, by the way) doesn't require that you expose your local Plex server to the Internet, thereby opening yet one more attack vector. Maybe a few Sonos engineers should take a few Google engineers to lunch and ask them how on earth they do it.
Userlevel 7
Badge +21
Chromecast Audio is driven by the apps that are playing the music. The Plex app tells the Chromecast device what server to connect to and what to play. The app is able to tell the Chromecast Audio to connect directly to the server since they're on the same network.

Sonos is definitely not the same as Chromecast Audio. You use Sonos' app to add music services to your system, then select what to play from those services. They're now allowing other services to control Sonos as well, though the choices are still a bit limited there (Spotify and Pandora, so far). And it's still not exactly the same as Chromecast Audio.

Plex on Sonos is treated the same as any other internet-based music service on Sonos. Your Sonos device communicates with Plex's servers on the internet, and Plex's servers use the Remote Access functionality to access your Plex server to provide song information to your Sonos device. When it comes time to play the music, Plex's servers tell your Sonos device to play directly from your Plex server (though in somewhat of a roundabout fashion). A lot of that is limitation in how Plex designed their Sonos "app"... unfortunately, since its appearance as a beta service in Sonos, Plex has done absolutely ZERO further development on it to change or improve things. Any issues with how it works, or doesn't work, should be taken up with Plex.
Hi Mike V, You seem so very knowledgeable on all matters Sonos could I ask you a question regarding port forwarding. I have posted on here before about the problem I am having with my Sonos Play5 not connecting to my Plex server. I add Plex to the Sonos music service, link it via the Plex code which gives me a green tick to say it is now linked but when I try to open my Plex music folder to play I get the "unable to connect to this server" screen. I have checked that the Plex remote access is on with a green tick but it makes no difference Sonos still won't connect. For a while, it did work if I was on my VPN connection but even that now no longer works. I have had several emails with Sonos support but they have been unable to come up with a fix. The frustrating thing is the Plex easily connects quite happily with other devices just not the Sonos. I am at my wit's end so not knowing how to move forward I have been reading your advice avidly and you have talked about port forwarding via the router as a possible solution but I have never done that before could I ask you for idiots guide on how to port forward? I do know how to access my Arris TG2492LG router but then I am lost and I am scared to change anything in case I mess up my internet connection. The Sonos is using my local home wifi. Many thanks
Userlevel 7
Badge +21
BTW, for anyone that might be following this topic... (and apparently the last post that I missed a few months ago)... updates made to Plex for Sonos earlier this week should no longer require the NAT loopback/hairpin functionality. Sonos will now use the LAN address of your Plex server if possible.

This can introduce potential issues with DNS rebinding, so you may either need to change settings of the DNS forwarder (i.e. dnsmasq) or resolver (i.e. unbound) on your router, or set Plex to prefer secure connections rather than require them... but the hairpin/loopback option is no longer required. I've removed it from my router and am still able to play music from my Plex server.

More info on DNS rebinding and secure connections can be found in this Plex support article: Secure Connections - Why doesn't it work - DNS Rebinding

I do believe remote access is still required though... browsing your library likely still goes through Plex's cloud servers.
hmm.. we're on a boat with whatever Internet we can get and not able to do plex remote access. Reverted my nighthawk router to old firmware to get SMB v1 back so I can access a hard drive on it's USB.
Would love to see Sonos implement SMB v2 and v3 as well as support plex without Internet connectivity.
Hi MikeV,
Thanks for your update on this topic. Not being very techy some of the descriptions about "DNS Rebinding" goes completely over my head, but I can only say that without changing anything other than reinstalling the Plex app on my Sonos paly5 it now seems to be working and is playing my music from the Plex server as I write so something must have changed. Having said that I found that I could connect my Sonos direct to my NAS storage so could play my music library from there so Plex was not so necessary after all, but thanks for all your help and advice... let's hope Plex /Sonos still keeps working long term!