ytdl-org/youtube-dl · error · Socks5Error
all offered authentication methods were rejected
Error message
all offered authentication methods were rejected
What it means
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.
Source
Thrown at youtube_dl/socks.py:199
packet = compat_struct_pack('!B', SOCKS5_VERSION)
auth_methods = [Socks5Auth.AUTH_NONE]
if self._proxy.username and self._proxy.password:
auth_methods.append(Socks5Auth.AUTH_USER_PASS)
packet += compat_struct_pack('!B', len(auth_methods))
packet += compat_struct_pack('!{0}B'.format(len(auth_methods)), *auth_methods)
self.sendall(packet)
version, method = self._recv_bytes(2)
self._check_response_version(SOCKS5_VERSION, version)
if method == Socks5Auth.AUTH_NO_ACCEPTABLE or (
method == Socks5Auth.AUTH_USER_PASS and (not self._proxy.username or not self._proxy.password)):
self.close()
raise Socks5Error(Socks5Auth.AUTH_NO_ACCEPTABLE)
if method == Socks5Auth.AUTH_USER_PASS:
username = self._proxy.username.encode('utf-8')
password = self._proxy.password.encode('utf-8')
packet = compat_struct_pack('!B', SOCKS5_USER_AUTH_VERSION)
packet += self._len_and_data(username) + self._len_and_data(password)
self.sendall(packet)
version, status = self._recv_bytes(2)
self._check_response_version(SOCKS5_USER_AUTH_VERSION, version)
if status != SOCKS5_USER_AUTH_SUCCESS:
self.close()
raise Socks5Error(Socks5Error.ERR_GENERAL_FAILURE)
def _setup_socks5(self, address):
destaddr, port = addressView on GitHub (pinned to 956b8c5855)
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)
Example fix
# before youtube-dl --proxy 'socks5://proxy.example.com:1080' URL # after youtube-dl --proxy 'socks5://alice:p%40ssword@proxy.example.com:1080' URL
Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlsplit
def socks_proxy_has_credentials(proxy_url):
parts = urlsplit(proxy_url)
return parts.scheme.startswith('socks5') and bool(parts.username) and bool(parts.password)
if opts['proxy'].startswith('socks5') and not socks_proxy_has_credentials(opts['proxy']):
raise ValueError('this SOCKS5 proxy requires user:pass in the URL') Try / catch
try:
ydl.download([url])
except Exception as e:
if 'all offered authentication methods were rejected' in str(e):
# config problem, not transient: add credentials and run once more
opts['proxy'] = 'socks5://%s:%s@host:1080' % (user, quoted_pass)
ydl.download([url]) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- No such Python version: %s
- {0} bytes missing
- Invalid response version from server. Expected {0:02x} got {
- This video is only available for users of participating TV p
- We're sorry, but either the User ID or Password entered is n
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/81cdb74db93f0c03.
Report an issue: GitHub.