ytdl-org/youtube-dl · error · ExtractorError

Unable to login, incorrect username and/or password

Error message

Unable to login, incorrect username and/or password

What it means

Login-failure error from VKBaseIE._login: after POSTing the login form to login.vk.com/?act=login, the returned page contains the marker 'onLoginFailed'. The extractor interprets that marker as a rejected username/password pair and raises with expected=True.

Source

Thrown at youtube_dl/extractor/vk.py:59

        login_form = self._hidden_inputs(login_page)

        login_form.update({
            'email': username.encode('cp1251'),
            'pass': password.encode('cp1251'),
        })

        # vk serves two same remixlhk cookies in Set-Cookie header and expects
        # first one to be actually set
        self._apply_first_set_cookie_header(url_handle, 'remixlhk')

        login_page = self._download_webpage(
            'https://login.vk.com/?act=login', None,
            note='Logging in',
            data=urlencode_postdata(login_form))

        if re.search(r'onLoginFailed', login_page):
            raise ExtractorError(
                'Unable to login, incorrect username and/or password', expected=True)

    def _real_initialize(self):
        self._login()

    def _download_payload(self, path, video_id, data, fatal=True):
        data['al'] = 1
        code, payload = self._download_json(
            'https://vk.com/%s.php' % path, video_id,
            data=urlencode_postdata(data), fatal=fatal,
            headers={'X-Requested-With': 'XMLHttpRequest'})['payload']
        if code == '3':
            self.raise_login_required()
        elif code == '8':
            raise ExtractorError(clean_html(payload[0][1:-1]), expected=True)
        return payload

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Verify the VK username/password are correct by logging in at vk.com in a browser
  2. Disable the login (extract without -u/-p) if the video is public
  3. If 2FA or an unusual-location check is triggered, confirm the login on VK's side or log in from a trusted IP first

Example fix

# before
youtube-dl -u user@mail.com -p badpass https://vk.com/video-123_456
# after (public video, no login needed)
youtube-dl https://vk.com/video-123_456
Defensive patterns

Strategy: try-catch

Try / catch

from youtube_dl.utils import ExtractorError
try:
    ydl.extract_info(url)
except ExtractorError as e:
    if 'Unable to login' in str(e):
        opts.pop('username', None); opts.pop('password', None)
        youtube_dl.YoutubeDL(opts).extract_info(url)  # retry anonymous

Prevention

When it happens

Trigger: Invoking any VK extractor with -u/--username and -p/--password credentials that VK rejects, i.e. the login response HTML matches r'onLoginFailed'.

Common situations: Wrong password; account with 2FA/SMS confirmation enabled; VK flagging logins from datacenter IPs; stale credentials in a saved .netrc.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/f48ee7e1ea50d954. Report an issue: GitHub.