Plex token


I did instal Plex, added the component to HA, then it askes for a token. I have been looking everywhere, trying to follow the docs but cannot find it

Any idé where i can find it?

1 Like

In the documentation of the component there is a link that’s describing how you can find the plex token.

I had the same issue and then change the browser to Edge and it showed in the URL

I have tryed sevral times , but after add X-Plex-Token show message > Failed to register, please try again.

Same issue here unfortunately.

I’m also seeing the same. “Failed to register, please try again.”

Same issue here too

Did you try to add the token manually in your plex.conf?

can’t find plex.conf file in /home/homeassistant/.homeassistant

I’d start by making sure home-assistant has permission to create files in your configuration directory. You can always make your own file as well.

I had the same problem, but when I change the secured connection option from “requiered” to “prefered” in my Plex Server configuration, it works perfectly!

I think something happened in an update of hass. My Plex was working (although I had some errors in log, I could see what was playing in my media_player), and now all of a sudden the configurator is showing up for me again and I can’t seem to get it working.

I got it working by creating the plex.conf file along side my configuration.yaml. The contents look like this

{"": {"token": "MY_TOKEN_HERE"}}

I seem to be having some errors with plex also., I added the plex.conf and do seem to get some feed on the default page but I also sent up a sensor but this never works

errors I am seeing are

17-05-18 07:14:12 ERROR (Thread-5) [plexapi] (401) unauthorized
17-05-18 07:14:12 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform plex
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/plexapi/”, line 47, in _connect
return self.query(’/’)
File “/home/homeassistant/.homeassistant/deps/plexapi/”, line 110, in query
raise BadRequest(’(%s) %s’ % (response.status_code, codename))
plexapi.exceptions.BadRequest: (401) unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/”, line 155, in _async_setup_platform
entity_platform.schedule_add_entities, discovery_info
File “/usr/lib/python3.4/asyncio/”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/”, line 52, in setup_platform
name, plex_url, plex_user, plex_password, plex_server)])
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/”, line 74, in init
self._server = PlexServer(plex_url)
File “/home/homeassistant/.homeassistant/deps/plexapi/”, line 27, in init
data = self._connect()
File “/home/homeassistant/.homeassistant/deps/plexapi/”, line 50, in _connect
raise NotFound(‘No server found at: %s’ % self.baseurl)
plexapi.exceptions.NotFound: No server found at:

You can also get the X-Token using this URL for those struggling to find your token.

Sign into and then click the link below.


I too am having difficulties setting up Plex, I have the correct token as verified using various methods, but still get a connection refused error.
HTTPConnectionPool(host='XX.XX.XX.XXX', port=18439): Max retries exceeded with url: /?X-Plex-Token=XXXXXXXXXXXXXXXX (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x6da64250>: Failed to establish a new connection: [Errno 111] Connection refused',))

I have tried deleting the device from plex and generating a new token, creating a custom app token and using/not using the plex.conf file all result in the same error, when I change the token, the error still shows the previous token, which is strange, maybe it is being stored somewhere and not getting updated when changed?

I am at a loss as what to try next, any help would be appreciated.


Thanks for this. I see a lot of tokens in there, which one do we need?

EDIT: I just tried one and it worked, so either I got lucky or any of them will work.

I would like to ask the same question as @thescreamingdrills regarding tokens if you could help.

@Molodax @thescreamingdrills

You can locate the correct device by searching for the device name in the XML and using the Plex Token for the device.

For example if you were an Intel NUC for hosting your Home Assistance Instance as I am, the computer name is located under Device name=“Hass_NUC” and further into the code block there is the Plex token named token="AAAAAAAAAA"

<Device name="Hass_NUC" publicAddress="222.111.333.222" product="PlexAPI" productVersion="3.0.6" platform="Linux" platformVersion="4.4.0-116-generic" device="Linux" model="" vendor="" provides="controller" clientIdentifier="0x94c691152d5b" version="3.0.6" id="204766410" token="AAAAAAAAAA" createdAt="1521394456" lastSeenAt="1521394456" screenResolution="" screenDensity=""></Device>

Hope this helps, please let me know if I can be any further assistance.

The devices names are also reflected on the Plex server settings page which may help you identify your device.

Settings > Devices > Other - (if using Linux)


XML has been edited to preserve security for my devices

Thank you for the explanation. It seems that I am trying to use the correct token, however, still have “Failed to register, please try again.”
I don’t own my own Plex server but use a shared library on my android TV with Plex. Do you know if it still possible to use the Plex media player component in such case?