{"record":{"id":"02fc65bb3f32c698","repo":"arduino/Arduino","slug":"maxretryerror-self-url-e","errorCode":null,"errorMessage":"MaxRetryError(self, url, e)","messagePattern":"MaxRetryError\\(self, url, e\\)","errorType":"exception","errorClass":"MaxRetryError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py","lineNumber":465,"sourceCode":"            raise TimeoutError(self, \"Request timed out. (timeout=%s)\" %\n                               timeout)\n\n        except BaseSSLError as e:\n            # SSL certificate error\n            raise SSLError(e)\n\n        except CertificateError as e:\n            # Name mismatch\n            raise SSLError(e)\n\n        except (HTTPException, SocketError) as e:\n            # Connection broken, discard. It will be replaced next _get_conn().\n            conn = None\n            # This is necessary so we can access e below\n            err = e\n\n            if retries == 0:\n                raise MaxRetryError(self, url, e)\n\n        finally:\n            if release_conn:\n                # Put the connection back to be reused. If the connection is\n                # expired then it will be None, which will get replaced with a\n                # fresh connection during _get_conn.\n                self._put_conn(conn)\n\n        if not conn:\n            # Try again\n            log.warn(\"Retrying (%d attempts remain) after connection \"\n                     \"broken by '%r': %s\" % (retries, err, url))\n            return self.urlopen(method, url, body, headers, retries - 1,\n                                redirect, assert_same_host,\n                                timeout=timeout, pool_timeout=pool_timeout,\n                                release_conn=release_conn, **response_kw)\n\n        # Handle redirect?","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py#L447-L483","documentation":"urllib3's HTTPConnectionPool.urlopen raises MaxRetryError(self, url, e) when retries is exhausted and the connection broke mid-request (HTTPException or SocketError after the request was sent). The MaxRetryError wraps the last underlying exception, so the retry budget was consumed by connection-level failures.","triggerScenarios":"Calling pool.urlopen(..., retries=0) or exhausting the default retry count while the socket dies (connection reset, remote close, keep-alive race), or any SocketError/HTTPException during the request when retries==0.","commonSituations":"Server closes idle keep-alive connections; flaky network or LB dropping connections; connecting to a service that is down or behind a rejecting proxy; retries=0 configured (e.g. by requests' HTTPAdapter defaults in old versions) so a single transient reset aborts.","solutions":["Configure retries: urllib3.Retry(connect=3, read=3, backoff_factor=0.5) mounted on requests' HTTPAdapter","Retry with idempotent requests, or disable urllib3 keep-alive (Connection: close header) to avoid stale-connection resets","Check server/proxy health and network stability (the wrapped .reason exception tells the root cause)","Increase retries for read errors if the endpoint is idempotent"],"exampleFix":"# before: single-shot, transient reset fails\nrequests.get('http://svc/api')\n# after\nimport requests\nfrom requests.adapters import HTTPAdapter\nfrom urllib3.util.retry import Retry\ns = requests.Session()\ns.mount('http://', HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5)))\ns.get('http://svc/api')","handlingStrategy":"retry","validationCode":"from urllib3.util.retry import Retry\nretry = Retry(total=3, connect=3, read=3, backoff_factor=0.5,\n              status_forcelist=(500, 502, 503, 504))\n# sanity check the endpoint before real traffic\nrequests.head(base_url, timeout=5)","typeGuard":null,"tryCatchPattern":"from requests.exceptions import ConnectionError, MaxRetryError\ntry:\n    r = session.get(url, timeout=10)\nexcept (MaxRetryError, ConnectionError) as e:\n    log.warning('connection retries exhausted: %s', getattr(e, 'reason', e))\n    r = None  # fall back or alert","preventionTips":["Mount a Retry policy on every HTTPAdapter instead of relying on defaults","Only retry idempotent requests (or make them idempotent)","Send 'Connection: close' or disable keep-alive against servers that aggressively reap idle connections","Alert on the wrapped .reason to catch persistent outages early"],"tags":["python","network","retry","urllib3"],"backgroundTag":"max-retries-exceeded","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}