{"id":"077f5c8b824602e8","repo":"aio-libs/aiohttp","slug":"aiohttp-only-supports-http-s-proxies-got-proxy","errorCode":null,"errorMessage":"aiohttp only supports http(s) proxies (got: {proxy.scheme!r}).\nSee third-party libraries for other proxy schemes.","messagePattern":"aiohttp only supports http\\(s\\) proxies \\(got: (.+?)\\)\\.\nSee third-party libraries for other proxy schemes\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"aiohttp/client_reqrep.py","lineNumber":1388,"sourceCode":"            and self.headers[hdrs.EXPECT].lower() == \"100-continue\"\n        ):\n            expect = True\n\n        if expect:\n            self._continue = self.loop.create_future()\n\n    def _update_proxy(\n        self,\n        proxy: URL | None,\n        proxy_headers: CIMultiDict[str] | None,\n    ) -> None:\n        if proxy is None:\n            self.proxy = None\n            self.proxy_headers = None\n            return\n\n        if proxy.scheme not in HTTP_AND_EMPTY_SCHEMA_SET:\n            raise ValueError(\n                f\"aiohttp only supports http(s) proxies (got: {proxy.scheme!r}).\\n\"\n                \"See third-party libraries for other proxy schemes.\"\n            )\n\n        # URL-embedded credentials on the proxy map to Proxy-Authorization.\n        if proxy.raw_user or proxy.raw_password:\n            auth_header = encode_basic_auth(proxy.user or \"\", proxy.password or \"\")\n            if proxy_headers is None:\n                proxy_headers = CIMultiDict()\n            proxy_headers.setdefault(hdrs.PROXY_AUTHORIZATION, auth_header)\n            proxy = proxy.with_user(None)\n        self.proxy = proxy\n        self.proxy_headers = proxy_headers\n\n    def _create_response(\n        self,\n        task: asyncio.Task[None] | None,\n        stream_writer: AbstractStreamWriter,","sourceCodeStart":1370,"sourceCodeEnd":1406,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/c0ef574e29109210e96e652771ae4e7b88615fa4/aiohttp/client_reqrep.py#L1370-L1406","documentation":"Raised as ValueError in ClientRequest when the configured proxy URL uses a scheme other than http or https. aiohttp's connector only knows how to tunnel through HTTP/HTTPS (CONNECT for HTTPS targets, plain forwarding for HTTP); SOCKS and other schemes require a third-party connector.","triggerScenarios":"Fires at line 1387-1391 when proxy.scheme is not in HTTP_AND_EMPTY_SCHEMA_SET. Triggered by passing proxy='socks5://127.0.0.1:1080', proxy='ftp://...', or similar non-http(s) proxy URLs.","commonSituations":"Using a SOCKS proxy (socks5h://) directly with aiohttp; env vars HTTPS_PROXY set to a socks URL; misconfigured corporate proxy scheme.","solutions":["Use an http(s) proxy URL, e.g. 'http://proxy.local:8080'.","For SOCKS proxies install aiohttp-socks (or aiohttp_socks) and use its ProxyConnector.","Check the HTTP_PROXY / HTTPS_PROXY environment variables for a non-http scheme."],"exampleFix":"# before\nconnector = aiohttp.TCPConnector()\nawait session.get(url, proxy='socks5://127.0.0.1:1080')\n# after - use a SOCKS-aware connector\nfrom aiohttp_socks import ProxyConnector\nconnector = ProxyConnector.from_url('socks5://127.0.0.1:1080')\nasync with aiohttp.ClientSession(connector=connector) as session:\n    await session.get(url)","handlingStrategy":"validation","validationCode":"from yarl import URL\nproxy = URL(proxy_url)\nif proxy.scheme not in {'http', 'https'}:\n    raise ValueError(f'aiohttp cannot use {proxy.scheme!r} proxies; use aiohttp_socks for SOCKS')","typeGuard":"def is_http_proxy(proxy_url) -> bool:\n    from yarl import URL\n    return URL(proxy_url).scheme in {'http', 'https'}","tryCatchPattern":null,"preventionTips":["Use http(s) proxy URLs with aiohttp directly.","Install aiohttp_socks and a ProxyConnector for SOCKS proxies.","Sanity-check HTTP_PROXY/HTTPS_PROXY env vars at startup."],"tags":["proxy","http-client","configuration","socks"],"analyzedSha":"c0ef574e29109210e96e652771ae4e7b88615fa4","analyzedAt":"2026-08-04T19:51:05.467Z","schemaVersion":2}