{"id":"4a7663004a1d978e","repo":"python-poetry/poetry","slug":"error-connecting-to-repository","errorCode":null,"errorMessage":"Error connecting to repository","messagePattern":"Error connecting to repository","errorType":"http","errorClass":"UploadError","httpStatus":null,"severity":"error","filePath":"src/poetry/publishing/uploader.py","lineNumber":292,"sourceCode":"                    )\n                    bar.display()\n                else:\n                    resp.raise_for_status()\n\n            except requests.RequestException as e:\n                if self._io.output.is_decorated():\n                    self._io.overwrite(\n                        f\" - Uploading <c1>{file.name}</c1> <error>FAILED</>\"\n                    )\n\n                if e.response is not None:\n                    message = (\n                        f\"HTTP Error {e.response.status_code}: \"\n                        f\"{e.response.reason} | {e.response.content!r}\"\n                    )\n                    raise UploadError(message) from e\n\n                raise UploadError(\"Error connecting to repository\") from e\n\n            finally:\n                self._io.write_line(\"\")\n\n    def _register(self, session: requests.Session, url: str) -> requests.Response:\n        \"\"\"\n        Register a package to a repository.\n        \"\"\"\n        data = self.post_data(self.files[0])\n        data.update({\":action\": \"submit\", \"protocol_version\": \"1\"})\n\n        data_to_send = self._prepare_data(data)\n        encoder = MultipartEncoder(data_to_send)\n        resp = session.post(\n            url,\n            data=encoder,\n            allow_redirects=False,\n            headers={\"Content-Type\": encoder.content_type},","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/publishing/uploader.py#L274-L310","documentation":"Raised by Uploader._upload_file() in the requests.RequestException handler when the caught exception has no .response — i.e. the request never reached a server response. This covers connection-level failures (DNS, refused connection, TLS, timeout). It is the fallback counterpart to error 71.","triggerScenarios":"session.post() raises a ConnectionError, ConnectTimeout, SSLError, or ReadTimeout before any HTTP response is received; the handler sees e.response is None and raises UploadError('Error connecting to repository').","commonSituations":"No/lost internet connectivity; DNS resolution failure for the index hostname; corporate proxy or firewall blocking the upload; TLS certificate verification failure; the index server is down; REQUESTS_TIMEOUT exceeded on a slow link.","solutions":["Check connectivity to the repository URL: `curl -v <url>`.","If behind a proxy, configure HTTPS_PROXY / Poetry's proxy settings.","For TLS errors, verify CA certs and the system clock; consider the configured cert options.","Retry on transient network drops; for chronic slowness, review REQUESTS_TIMEOUT and link quality.","Confirm the repository hostname is correct and resolvable."],"exampleFix":"// before: behind corporate proxy, connection fails\nUploadError: Error connecting to repository\n\n// after\n$ export HTTPS_PROXY=http://proxy.corp:8080\n$ poetry publish -r internal","handlingStrategy":"retry","validationCode":"import socket\n\ndef host_is_reachable(url: str) -> bool:\n    from urllib.parse import urlparse\n    host = urlparse(url).hostname\n    try:\n        socket.gethostbyname(host)\n        return True\n    except OSError:\n        return False","typeGuard":null,"tryCatchPattern":"from poetry.publishing.uploader import UploadError\n\nimport time\n\nfor attempt in range(3):\n    try:\n        publisher.publish(...)\n        break\n    except UploadError as e:\n        if \"Error connecting to repository\" in str(e) and attempt < 2:\n            time.sleep(2 ** attempt)\n            continue\n        raise","preventionTips":["Verify network/proxy connectivity before publishing.","Set HTTPS_PROXY in corporate environments.","Ensure system CA certs and clock are correct for TLS.","Retry transient connection drops; investigate chronic failures."],"tags":["publishing","network","connection","proxy"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}