This isn't a solution to your specific problem, but I'm putting it here because this thread is the top Google result for "SSL: CERTIFICATE_VERIFY_FAILED", and it lead me on a wild goose chase.

If you have installed Python 3.6 on OSX and are getting the "SSL: CERTIFICATE_VERIFY_FAILED" error when trying to connect to an https:// site, it's probably because Python 3.6 on OSX has no certificates at all, and can't validate any SSL connections. This is a change for 3.6 on OSX, and requires a post-install step, which installs the certifi package of certificates. This is documented in the file ReadMe.rtf, which you can find at /Applications/Python\ 3.6/ReadMe.rtf (see also the file Conclusion.rtf, and the script build-installer.py that generates the macOS installer).

The ReadMe will have you run the post-install script at

/Applications/Python\ 3.10/Install\ Certificates.command (Terminal App, this command alone should, fix the issue. Be sure to update the file path using your current subversion.)

(its source is install_certificates.command), which:

  • first installs the Python package certifi, and
  • then creates a symbolic link from the OpenSSL certificates file to the certificates file installed by the package certifi.

Release notes have some more info: https://www.python.org/downloads/release/python-360/

On newer versions of Python, there is more documentation about this:

  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/ReadMe.rtf#L22-L34
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/Conclusion.rtf#L15-L19
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/Welcome.rtf#L23-L25
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/install_certificates.command
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/README.rst
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/build-installer.py#L239-L246
Answer from Craig Glennie on Stack Overflow
Top answer
1 of 16
618

This isn't a solution to your specific problem, but I'm putting it here because this thread is the top Google result for "SSL: CERTIFICATE_VERIFY_FAILED", and it lead me on a wild goose chase.

If you have installed Python 3.6 on OSX and are getting the "SSL: CERTIFICATE_VERIFY_FAILED" error when trying to connect to an https:// site, it's probably because Python 3.6 on OSX has no certificates at all, and can't validate any SSL connections. This is a change for 3.6 on OSX, and requires a post-install step, which installs the certifi package of certificates. This is documented in the file ReadMe.rtf, which you can find at /Applications/Python\ 3.6/ReadMe.rtf (see also the file Conclusion.rtf, and the script build-installer.py that generates the macOS installer).

The ReadMe will have you run the post-install script at

/Applications/Python\ 3.10/Install\ Certificates.command (Terminal App, this command alone should, fix the issue. Be sure to update the file path using your current subversion.)

(its source is install_certificates.command), which:

  • first installs the Python package certifi, and
  • then creates a symbolic link from the OpenSSL certificates file to the certificates file installed by the package certifi.

Release notes have some more info: https://www.python.org/downloads/release/python-360/

On newer versions of Python, there is more documentation about this:

  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/ReadMe.rtf#L22-L34
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/Conclusion.rtf#L15-L19
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/Welcome.rtf#L23-L25
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/resources/install_certificates.command
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/README.rst
  • https://github.com/python/cpython/blob/e05a703848473b0365886dcc593cbddc46609f29/Mac/BuildScript/build-installer.py#L239-L246
2 of 16
409

If you just want to bypass verification, you can create a new SSLContext. By default newly created contexts use CERT_NONE.

Be careful with this as stated in section 17.3.7.2.1

When calling the SSLContext constructor directly, CERT_NONE is the default. Since it does not authenticate the other peer, it can be insecure, especially in client mode where most of time you would like to ensure the authenticity of the server you’re talking to. Therefore, when in client mode, it is highly recommended to use CERT_REQUIRED.

But if you just want it to work now for some other reason you can do the following, you'll have to import ssl as well:

input = input.replace("!web ", "")      
url = "https://domainsearch.p.mashape.com/index.php?name=" + input
req = urllib2.Request(url, headers={ 'X-Mashape-Key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' })
gcontext = ssl.SSLContext()  # Only for gangstars
info = urllib2.urlopen(req, context=gcontext).read()
Message.Chat.SendMessage ("" + info)

This should get round your problem but you're not really solving any of the issues, but you won't see the [SSL: CERTIFICATE_VERIFY_FAILED] because you now aren't verifying the cert!

To add to the above, if you want to know more about why you are seeing these issues you will want to have a look at PEP 476.

This PEP proposes to enable verification of X509 certificate signatures, as well as hostname verification for Python's HTTP clients by default, subject to opt-out on a per-call basis. This change would be applied to Python 2.7, Python 3.4, and Python 3.5.

There is an advised opt out which isn't dissimilar to my advice above:

import ssl

# This restores the same behavior as before.
context = ssl._create_unverified_context()
urllib.urlopen("https://no-valid-cert", context=context)

It also features a highly discouraged option via monkeypatching which you don't often see in python:

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

Which overrides the default function for context creation with the function to create an unverified context.

Please note with this as stated in the PEP:

This guidance is aimed primarily at system administrators that wish to adopt newer versions of Python that implement this PEP in legacy environments that do not yet support certificate verification on HTTPS connections. For example, an administrator may opt out by adding the monkeypatch above to sitecustomize.py in their Standard Operating Environment for Python. Applications and libraries SHOULD NOT be making this change process wide (except perhaps in response to a system administrator controlled configuration setting).

If you want to read a paper on why not validating certs is bad in software you can find it here!

Discussions

Update to Python 3.11 got SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)')))
In any case, please remember that handling SSL certificates can have security implications. Be careful not to disable certificate verification in your production code, as it can expose you to security risks. More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
SSL errors in python 3.13
Hi I am using a self signed certificate and, when using it in python 3.9, it works fine, but when using it with python 3.13, i have this error requests.exceptions.SSLError: HTTPSConnectionPool(host=‘XXX’, port=443): Ma… More on discuss.python.org
🌐 discuss.python.org
5
0
April 24, 2025
SSL: CERTIFICATE_VERIFY_FAILED
Lol, I initially misread the title as "VERY_FAILED" instead of "VERIFY_FAILED". Anyway, tried: ...python3.8/Install\ Certificates.command with "No such file or directory" error. The thread says to run "/Applications/Python 3.10/Install Certificates.command", except with backslashes instead of quotes. The quotes are a lot less confusing than the backslashes. You seem to have used python3.8 instead of Python 3.8. The error message should give you a hing to go into the actual directory /Applications to see what is there. More on reddit.com
🌐 r/learnpython
9
1
December 10, 2023
SSL: certificate_verify_failed
Hello, I am trying to connect to the OpenAI api from python, a simple test, but I am not succeeding as I always get the same error: MaxRetryError: HTTPSConnectionPool(host=‘api.openai.com’, port=443): Max retries excee… More on community.openai.com
🌐 community.openai.com
19
1
January 9, 2023
People also ask

What does CERTIFICATE_VERIFY_FAILED mean in Python?
The CERTIFICATE_VERIFY_FAILED error occurs when Python cannot validate an SSL/TLS certificate while making HTTPS requests. Your script fails because Python's SSL module blocks connections to websites with certificates it considers untrusted, expired, or improperly configured. This happens most frequently when using libraries like urllib, requests, or pip to fetch data from secure websites.
🌐
sslinsights.com
sslinsights.com › home › wiki › how to fix ssl certificate_verify_failed error in python
Fix Python SSL CERTIFICATE_VERIFY_FAILED Error in 2026
Why does Python reject valid SSL certificates?
Python relies on a certificate authority (CA) bundle to verify website identities. When this bundle becomes outdated or missing, Python flags even legitimate certificates as suspicious. Corporate networks create another common trigger where company firewalls intercept HTTPS traffic using self-signed certificates that Python doesn't recognize.
🌐
sslinsights.com
sslinsights.com › home › wiki › how to fix ssl certificate_verify_failed error in python
Fix Python SSL CERTIFICATE_VERIFY_FAILED Error in 2026
Does updating Python fix SSL certificate errors?
Updating Python often resolves certificate errors because newer versions include updated CA bundles and improved SSL handling. Python 3.10+ comes with better certificate management and automatic certifi integration. However, you may still need to run the post-installation certificate script on macOS or manually update certifi on older systems.
🌐
sslinsights.com
sslinsights.com › home › wiki › how to fix ssl certificate_verify_failed error in python
Fix Python SSL CERTIFICATE_VERIFY_FAILED Error in 2026
🌐
DEV Community
dev.to › toby-patrick › how-to-fix-ssl-certificateverifyfailed-in-python-requests-35nl
How to Fix “SSL: CERTIFICATE_VERIFY_FAILED” in Python Requests - DEV Community
September 15, 2025 - If the server uses a self-signed certificate, Python won’t recognize it as trustworthy unless you manually configure your system to trust it. Some enterprise environments perform SSL inspection using internal certificates. These often trigger verification errors because Python doesn’t recognize the internal CA.
🌐
Github
chanind.github.io › python › 2023 › 08 › 30 › python-ssl-certificate-verify-failed.html
Solving Python SSL certificate verify failed on Linux / SGE | chanind.github.io
August 30, 2023 - I didn’t have any luck following most of what I found on Stack Overflow to solve this issue, but eventually stumbled on a solution combining ideas from Redhat’s guide to Python cert errors, and a Stack Overlow answer. Specifically, I needed to install certifi certs via pip install certifi, but this was not enough. I then needed to set an ENV var called SSL_CERT_FILE to the location of the certs installed via certifi.
🌐
Microsoft Learn
learn.microsoft.com › en-gb › answers › questions › 2077926 › update-to-python-3-11-got-sslerror(sslcertverifica
Update to Python 3.11 got SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)'))) - Microsoft Q&A
It seems like your Python installation is not configured to trust any Certificate Authorities (CAs). This can happen when Python can't find the system's set of trusted CAs. In Python 3.11, there might be a change in how SSL certificates are ...
Find elsewhere
🌐
Python.org
discuss.python.org › python help
SSL errors in python 3.13 - Python Help - Discussions on Python.org
April 24, 2025 - Hi I am using a self signed certificate and, when using it in python 3.9, it works fine, but when using it with python 3.13, i have this error requests.exceptions.SSLError: HTTPSConnectionPool(host=‘XXX’, port=443): Max retries exceeded with url: /XXX (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1028)’))) any idea what can i do to fix it?
🌐
Reddit
reddit.com › r/learnpython › ssl: certificate_verify_failed
r/learnpython on Reddit: SSL: CERTIFICATE_VERIFY_FAILED
December 10, 2023 -

Hello guys and thank you in advance,This error is driving me crazy.

System: macOS Sonoma 14.1 with Python 3.8 in a virtual environment

I want to run some code which will allow me to download a dataset from Github, as explained in a book I am reading:

import os
import tarfile
import urllib.request
DOWNLOAD_ROOT = "https://raw.githubusercontent.com/ageron/handson-ml2/master/"
HOUSING_PATH = os.path.join("datasets", "housing")
HOUSING_URL = DOWNLOAD_ROOT + "datasets/housing/housing.tgz"
def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH):
    if not os.path.isdir(housing_path):
        os.makedirs(housing_path)
    tgz_path = os.path.join(housing_path, "housing.tgz")
    urllib.request.urlretrieve(housing_url, tgz_path)
housing_tgz = tarfile.open(tgz_path)
housing_tgz.extractall(path=housing_path)
housing_tgz.close()
fetch_housing_data()

Error:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)>

From Stackoverflow I understand that I have to download manually the certificates and install them. I did so with pip install certifi and sub sequentially tried: ...python3.8/Install\ Certificates.command with "No such file or directory" error.

What am I doing wrong? Please keep in my mind I have a venv with Python 3.8 in it.

Thank You A LOT!

🌐
SSLInsights
sslinsights.com › home › wiki › how to fix ssl certificate_verify_failed error in python
Fix Python SSL CERTIFICATE_VERIFY_FAILED Error in 2026
2 weeks ago - Websites with expired certificates will load in browsers with manual confirmation but immediately fail in Python scripts. Check certificate expiration dates using openssl s_client -connect domain.com:443 -servername domain.com to verify validity ...
🌐
ClickSSL
clickssl.net › blog › ssl-certificate-verify-failed-error-in-python
How to Fix SSL: CERTIFICATE_VERIFY_FAILED Error In Python?
The root certificate needs to be issued by a trustworthy CA, or you may encounter an error like- “certificate verify failed: self-signed certificate in a certificate chain.” · If you see such an error, your certificate chain is tracked back to a self-signed certificate. Another error that is common in Python is pip SSL certificate_verify_failed.
🌐
Cheap SSL Web
cheapsslweb.com › home › how to fix “ssl: certificate_verify_failed” error in python?
Fix SSL: CERTIFICATE_VERIFY_FAILED Error in Python
December 8, 2025 - If the SSL certificate chain is broken or incomplete, the client cannot verify the SSL certificate, resulting in the certificate_verify_failed error. (Assuming the chain has a leaf and intermediate certificates, but the Root certificate is missing) ...
🌐
Sectigo
sectigostore.com › ssl resources › ssl errors › what is an ssl ‘certificate_verify_failed’ error and how do i resolve it?
What is an SSL ‘Certificate_Verify_Failed’ Error and How Do I Resolve It? - SectigoStore
July 1, 2024 - SSL certificate_verify_failed errors typically occur as a result of outdated Python default certificates or invalid root certificates. If you’re a website owner and you’re receiving this error, it could be because you’re not using a valid ...
🌐
How to Use Linux
howtouselinux.com › home › 5 ways to fix ssl: certificate_verify_failed in python
5 Ways to fix SSL: CERTIFICATE_VERIFY_FAILED in Python - howtouselinux
October 22, 2025 - By setting verify=False, you are instructing requests to skip SSL certificate verification and accept any certificate presented by the server, regardless of its validity. Verify that the server is sending the complete certificate chain, including ...
🌐
Chainstack Support
support.chainstack.com › hc › en-us › articles › 9117198436249-Common-SSL-Issues-on-Python-and-How-to-Fix-it
Common SSL Issues on Python and How to Fix it – Chainstack Support
import ssl import certifi from urllib.request import urlopen request = "https://nd-123-456-789.p2pify.com/901c7d18b72538fd3324248e1234" urlopen(request, context=ssl.create_default_context(cafile=certifi.where())) If the quick fix is not effective in your case, please follow the applicable ones from the list below. ... import ssl ssl._create_default_https_context = ssl._create_unverified_context urllib2.urlopen(“https://google.com”).read() 3. Use requests module and set ssl verify to false
🌐
Better Stack
betterstack.com › community › questions › urllib-and-ssl-certificate-verify-failed-error
Urllib and "Ssl: Certificate_verify_failed" Error | Better Stack Community
The ssl: certificate_verify_failed error when using Python's urllib library indicates that the SSL certificate of the server you're trying to connect to cannot be verified. This typically happens when the server's certificate chain cannot be ...
🌐
Python.org
discuss.python.org › ideas
Improve error message for SSL: CERTIFICATE_VERIFY_FAILED error - Ideas - Discussions on Python.org
September 27, 2022 - I propose to clarify the SSL: CERTIFICATE_VERIFY_FAILED error message on macOS to encourage users to install the appropriate certificates rather than just deactivating SSL verification. The Python installer for macOS does not automatically install the SSL root certificates, and many users don’t notice the message recommending that they run Install Certificates.command.
🌐
Reddit
reddit.com › r/learnpython › ssl certificate verify failed when downloading pip packages
r/learnpython on Reddit: SSL Certificate Verify Failed when Downloading Pip Packages
November 17, 2023 -

Hi all,

So I set up a private pypi server and configured an nginx server to access this pypi server via a proxy pass. When I go to install packages from the url though which is the nginx server, I am getting an error that says "There was a problem confirming the ssl certification: HTTPSConnectionPool ... Caused by SSLError(SSLCertVerificationError(1, '[SSL:CERTIFICATE_VERIFY_FAILED] certificate verify failed....". I'm wondering how I can fix this in the command prompt and in an ide where I can setup the link to the server as a package source like in PyCharm for example.

Thanks for the help.

🌐
Python.org
discuss.python.org › python help
"SSL: CERTIFICATE_VERIFY_FAILED" error on Python 3.9.6 (Windows 10) - Python Help - Discussions on Python.org
May 5, 2022 - Hi! I’m new with Python and I have been following some tutorials and based on one of them I have the following piece of code: from scrapy import Selector from urllib.request import urlopen html = urlopen("https://www.pythonparatodos.com.br/formulario.html") sel = Selector(text = html.read()) lista = sel.xpath('//input[@type="text"]') print(lista) for selector in lista: print(selector) The URL is easily accessed through a browser but when I run the code I got the following errors: C:\Use...