{"record":{"id":"81cdb74db93f0c03","repo":"ytdl-org/youtube-dl","slug":"all-offered-authentication-methods-were-rejected","errorCode":null,"errorMessage":"all offered authentication methods were rejected","messagePattern":"all offered authentication methods were rejected","errorType":"exception","errorClass":"Socks5Error","httpStatus":null,"severity":"error","filePath":"youtube_dl/socks.py","lineNumber":199,"sourceCode":"        packet = compat_struct_pack('!B', SOCKS5_VERSION)\n\n        auth_methods = [Socks5Auth.AUTH_NONE]\n        if self._proxy.username and self._proxy.password:\n            auth_methods.append(Socks5Auth.AUTH_USER_PASS)\n\n        packet += compat_struct_pack('!B', len(auth_methods))\n        packet += compat_struct_pack('!{0}B'.format(len(auth_methods)), *auth_methods)\n\n        self.sendall(packet)\n\n        version, method = self._recv_bytes(2)\n\n        self._check_response_version(SOCKS5_VERSION, version)\n\n        if method == Socks5Auth.AUTH_NO_ACCEPTABLE or (\n                method == Socks5Auth.AUTH_USER_PASS and (not self._proxy.username or not self._proxy.password)):\n            self.close()\n            raise Socks5Error(Socks5Auth.AUTH_NO_ACCEPTABLE)\n\n        if method == Socks5Auth.AUTH_USER_PASS:\n            username = self._proxy.username.encode('utf-8')\n            password = self._proxy.password.encode('utf-8')\n            packet = compat_struct_pack('!B', SOCKS5_USER_AUTH_VERSION)\n            packet += self._len_and_data(username) + self._len_and_data(password)\n            self.sendall(packet)\n\n            version, status = self._recv_bytes(2)\n\n            self._check_response_version(SOCKS5_USER_AUTH_VERSION, version)\n\n            if status != SOCKS5_USER_AUTH_SUCCESS:\n                self.close()\n                raise Socks5Error(Socks5Error.ERR_GENERAL_FAILURE)\n\n    def _setup_socks5(self, address):\n        destaddr, port = address","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/socks.py#L181-L217","documentation":"Raised as Socks5Error(AUTH_NO_ACCEPTABLE) after the SOCKS5 method negotiation when the server replies with method 0xFF (no acceptable methods) or selects username/password auth while the client has no username/password configured. The connection is closed and the single message 'all offered authentication methods were rejected' is raised.","triggerScenarios":"Using --proxy socks5://host:port where the proxy requires username/password authentication but no credentials were embedded in the proxy URL; or a proxy configured to accept only auth methods the client did not offer.","commonSituations":"Paid/private SOCKS5 proxies that mandate auth; credentials present in a config elsewhere but not passed to youtube-dl; URL-encoding mistakes that strip the user:pass part of the proxy URL.","solutions":["Include credentials in the proxy URL: --proxy 'socks5://user:pass@host:port'","URL-encode special characters in the password (@, :, /, #) when embedding them","Confirm the proxy account is active and the server accepts username/password auth (method 0x02)","If the proxy should be open, fix its configuration to also offer 'no auth' (0x00)"],"exampleFix":"# before\nyoutube-dl --proxy 'socks5://proxy.example.com:1080' URL\n# after\nyoutube-dl --proxy 'socks5://alice:p%40ssword@proxy.example.com:1080' URL","handlingStrategy":"validation","validationCode":"from urllib.parse import urlsplit\n\ndef socks_proxy_has_credentials(proxy_url):\n    parts = urlsplit(proxy_url)\n    return parts.scheme.startswith('socks5') and bool(parts.username) and bool(parts.password)\n\nif opts['proxy'].startswith('socks5') and not socks_proxy_has_credentials(opts['proxy']):\n    raise ValueError('this SOCKS5 proxy requires user:pass in the URL')","typeGuard":null,"tryCatchPattern":"try:\n    ydl.download([url])\nexcept Exception as e:\n    if 'all offered authentication methods were rejected' in str(e):\n        # config problem, not transient: add credentials and run once more\n        opts['proxy'] = 'socks5://%s:%s@host:1080' % (user, quoted_pass)\n        ydl.download([url])","preventionTips":["Always embed user:pass for private SOCKS5 proxies: socks5://user:pass@host:port","URL-encode special characters in proxy passwords","Retry only after changing credentials — the same anonymous request will fail identically"],"tags":["socks","proxy","authentication","connection-refused"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}