RemiRigal/Plex-Auto-Languages

Max retries exceeded with url: /api/v2/user

Closed this issue · 4 comments

Hey, I've been using this project for a while now and been absolutely loving it. Now recently I noticed it not functioning correctly anymore and therefore went to look in the logs from what I've seen, it seems there are problems with connecting to the api? I'm honestly not really sure, the plex url and token should be correct anyways.

Here are the logs:

PlexAutoLanguages    | Traceback (most recent call last):
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 203, in _new_conn
PlexAutoLanguages    |     sock = connection.create_connection(
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 60, in create_connection
PlexAutoLanguages    |     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
PlexAutoLanguages    |     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
PlexAutoLanguages    | socket.gaierror: [Errno -3] Try again
PlexAutoLanguages    |
PlexAutoLanguages    | The above exception was the direct cause of the following exception:
PlexAutoLanguages    |
PlexAutoLanguages    | Traceback (most recent call last):
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 790, in urlopen
PlexAutoLanguages    |     response = self._make_request(
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 491, in _make_request
PlexAutoLanguages    |     raise new_e
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 467, in _make_request
PlexAutoLanguages    |     self._validate_conn(conn)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn
PlexAutoLanguages    |     conn.connect()
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 611, in connect
PlexAutoLanguages    |     self.sock = sock = self._new_conn()
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 210, in _new_conn
PlexAutoLanguages    |     raise NameResolutionError(self.host, self, e) from e
PlexAutoLanguages    | urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x7fa6e06d9310>: Failed to resolve 'plex.tv' ([Errno -3] Try again)
PlexAutoLanguages    |
PlexAutoLanguages    | The above exception was the direct cause of the following exception:
PlexAutoLanguages    |
PlexAutoLanguages    | Traceback (most recent call last):
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 486, in send
PlexAutoLanguages    |     resp = conn.urlopen(
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 844, in urlopen
PlexAutoLanguages    |     retries = retries.increment(
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 515, in increment
PlexAutoLanguages    |     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
PlexAutoLanguages    | urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='plex.tv', port=443): Max retries exceeded with url: /api/v2/user (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7fa6e06d9310>: Failed to resolve 'plex.tv' ([Errno -3] Try again)"))
PlexAutoLanguages    |
PlexAutoLanguages    | During handling of the above exception, another exception occurred:
PlexAutoLanguages    |
PlexAutoLanguages    | Traceback (most recent call last):
PlexAutoLanguages    |   File "main.py", line 118, in <module>
PlexAutoLanguages    |     plex_auto_languages.start()
PlexAutoLanguages    |   File "main.py", line 68, in start
PlexAutoLanguages    |     self.init()
PlexAutoLanguages    |   File "main.py", line 45, in init
PlexAutoLanguages    |     self.plex = PlexServer(self.config.get("plex.url"), self.config.get("plex.token"), self.notifier, self.config)
PlexAutoLanguages    |   File "/app/plex_auto_languages/plex_server.py", line 103, in __init__
PlexAutoLanguages    |     self._user = self._get_logged_user()
PlexAutoLanguages    |   File "/app/plex_auto_languages/plex_server.py", line 142, in _get_logged_user
PlexAutoLanguages    |     plex_username = self._plex.myPlexAccount().username
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/plexapi/server.py", line 317, in myPlexAccount
PlexAutoLanguages    |     self._myPlexAccount = MyPlexAccount(token=self._token, session=self._session)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/plexapi/myplex.py", line 122, in __init__
PlexAutoLanguages    |     data, initpath = self._signin(username, password, code, remember, timeout)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/plexapi/myplex.py", line 127, in _signin
PlexAutoLanguages    |     return self.query(self.key), self.key
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/plexapi/myplex.py", line 229, in query
PlexAutoLanguages    |     response = method(url, headers=headers, timeout=timeout, **kwargs)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 602, in get
PlexAutoLanguages    |     return self.request("GET", url, **kwargs)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
PlexAutoLanguages    |     resp = self.send(prep, **send_kwargs)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
PlexAutoLanguages    |     r = adapter.send(request, **kwargs)
PlexAutoLanguages    |   File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
PlexAutoLanguages    |     raise ConnectionError(e, request=request)
PlexAutoLanguages    | requests.exceptions.ConnectionError: HTTPSConnectionPool(host='plex.tv', port=443): Max retries exceeded with url: /api/v2/user (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7fa6e06d9310>: Failed to resolve 'plex.tv' ([Errno -3] Try again)"))

Hi @NLion74, the error that you get is a DNS issue with the plex.tv domain. Since the authentication to Plex have to go through their servers, it's required to be able to send requests to this domain.

If you are using a custom DNS server (PiHole, AdGuard...), make sure that it's not blocking this domain. Please also check that your DNS is setup correctly on your machine. Are you using Docker to run Plex-Auto-Languages, what OS are you using ?

Last question, did it stop working completely since you got this error or does it still work from time to time ?

Hello @RemiRigal, thanks for your fast reply.

I am using adguard as my DNS server, it is however not used on this specific server. My /etc/resolv.conf contains nameserver 1.1.1.1. Also using the following prompt curl -I https://www.plex.tv/ outputs HTTP/2 200 showing the domain should be reachable.

I am running Plex-Auto-Languages using Docker on Debian 12. From what I have seen it seems to have completely stopped working.

After trying to update another docker container, I noticed it saying there'd be an issue with iptables. Now after quickly googling it, the first solution seems to have worked also fixing this in the process. I'm guessing this was an issue that still persisted from upgrading to debian 12. It is now working perfectly fine and was an issue caused on my side.

For anyone possibly may having the same issue, the steps are as follows:

sudo iptables -t filter -F
sudo iptables -t filter -X
systemctl restart docker

Awesome, glad to know your issue is resolved ! Thanks a lot for providing your solution, this may help others.

Enjoy the tool and do not hesitate to share some feedback !