Certificate did not match expected hostname - Hassio - Plex

Hi All,

Having issues with the integration of plex - system details as follows:

  • Synology NAS DS1817+ (DSM 6.2)
  • Hassio running in docker (version 0.97.2)
  • Plex addon - also running in docker (version 2.1.2)

At the moment I am accessing hass externally as I am away. Not sure if this would make a difference but thought it worth a mention.

Getting 3 error messages during a boot or restart.

Third error:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.0.152', port=32400): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError("hostname '192.168.0.152' doesn't match '*.0b7c342daf854162b7a298ca51c1750c.plex.direct'")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/plex/media_player.py", line 97, in setup_platform
    host, token, has_ssl, verify_ssl, hass, config, add_entities_callback
  File "/usr/src/homeassistant/homeassistant/components/plex/media_player.py", line 116, in setup_plexserver
    "%s://%s" % (http_prefix, host), token, cert_session
  File "/usr/local/lib/python3.7/site-packages/plexapi/server.py", line 102, in __init__
    data = self.query(self.key, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/plexapi/server.py", line 341, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='192.168.0.152', port=32400): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError("hostname '192.168.0.152' doesn't match '*.0b7c342daf854162b7a298ca51c1750c.plex.direct'")))

Second error:

Certificate did not match expected hostname: 192.168.0.152. Certificate: {'subject': ((('commonName', '*.0b7c342daf854162b7a298ca51c1750c.plex.direct'),),), 'subjectAltName': [('DNS', '*.0b7c342daf854162b7a298ca51c1750c.plex.direct')]}

First error:

Ended unfinished session (id=122 from 2019-08-22 00:35:44.276988)

Plex is working but because of these errors, there is no media player or sensors available to set up.

So far I have tried:

  • several claim codes
  • editing the json in the plex.conf file (ive used the local ip of my server and the duckdns address)
  • changing ssl to true and false
  • changing verify to true and false

Not sure where to go from here. Any help is appreciated.

Did you ever figure this out? I am running into the same issue.

No sorry, I migrated my whole hassio setup to an Ubuntu server running on a nuc… So much better!

If you’re still running into this issue, I strongly recommend:

  1. Removing the legacy plex.conf file.
  2. Removing your plex: section in the configuration file.
  3. Removing any existing Plex entries on the Integrations page.
  4. Adding a new Plex connection via the Integrations page, which will send you to plex.tv and handle all the hostname/SSL/token fun for you.