Search code examples
youtubeyoutube-dl

youtube-dl gave me an error about ssl


Following is the error that youtube-dl gave me. Another tool you-get gave me a similar error. What should I do to download videos from youtube.

[~] youtube-dl -f 137 https://youtu.be/0Ef9GudbxXY

17:27:23 [youtube] 0Ef9GudbxXY: Downloading webpage ERROR: Unable to download webpage: (caused by URLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))


Solution

  • This error means that there is a problem with the TLS certificate. Typical suspects are, in rough order descending likeliness, according to my experiences working as a youtube-dl developer:

    • Censorship by your country, especially if you are located in or near China, Pakistan, or other non-democratic countries. You can use a VPN or TOR with a bridge to avoid the censorship.
    • Censorship by your company, school, or ISP. Again, a VPN (or proxy) can avoid this.
    • Local anti-malware software trying to intercept connections.
    • Local malware software trying to intercept connections.
    • A proxy server that is now misbehaving. Add -v to the command line to see whether one is configured.
    • A local configuration problem, i.e. missing certificate store or so. This depends a lot on how you installed youtube-dl.
    • A configuration problem on YouTube's side.

    In any case, you can avoid certificate checking by passing in --no-check-certificate. However, note that this will allow nation states, ISPs, schools/companies, hackers, and other (semi-)malicious parties to log, intercept, and change your video traffic.

    Note: The video https://youtu.be/0Ef9GudbxXY is not available in format 137. Simply leave out -f to get the best available format.