Media_player.play_media URL error with Plex

Using 0.115.1, Calling media_player.play_media to any Plex target is resulting in a URL connection error.

It looks like it’s trying to connect to a link-local address instead of the IP of the machine that Plex is running on (or app.plex.tv)

Failed to call service media_player/play_media. HTTPConnectionPool(host='169.254.97.70', port=32400): 
Max retries exceeded with url: /player/playback/playMedia?address=10-0-1-220.REDACTED.plex.direct&commandID=3&containerKey=%2FplayQueues%2F9852%3Fwindow%3D100%26own%3D1&key=%2Fplaylists%2F61807&machineIdentifier=REDACTED&offset=0&port=32400&token=REDACTED&type=music 
(Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xa2ac8d90>: Failed to establish a new connection: [Errno 113] Host is unreachable'))

Has anyone encountered this? Everything is working fine with the plex entity sensors etc, so I am certain that the API connection otherwise is working correctly.

I have not seen this before. Was this a temporary issue or has it persisted?

The connection addresses are taken from Plex API calls as-is. Perhaps we’re receiving bad data somewhere.

Yep, still happening today. Plex is run with the official Mac Plex Server app on a Mac Mini on my network. Is there any API I can dig into to see?

Note: Make sure to sanitize any info/logs obtained below to remove tokens before sharing.

To start, I’d see how the Plex client addresses are being reported by the Plex server:

curl http://<PLEX_SERVER_IP>:32400/clients?X-Plex-Token=<TOKEN>

If that doesn’t give anything interesting, run the integration and library in debug:

logger:
  logs:
   homeassistant.components.plex: debug
   plexapi: debug

Another sanity check could be restarting your Plex server.

Yep, looks like I’m getting back link-local IPs for some players:

<Server name="LG OLED55B9PUA" host="169.254.97.70" address="169.254.97.70" port="32400" machineIdentifier="REDACTED" version="5.1.3" protocol="plex" product="Plex for LG" deviceClass="pc" protocolVersion="3" protocolCapabilities="timeline,playback,navigation,playqueues" />

I restarted and now I see the correct IPs. Super weird!

1 Like

I’m having this exact same problem with my LG TV as well, except it’s reporting 127.0.0.1 for both host and address. Restarting the TV, Plex Server and Home Assistant does not fix this like it did for Paul.