The problem you are having is caused by an untrusted SSL certificate.

Like dirk mentioned in a previous comment, the quickest fix is setting verify=False:

requests.get('https://example.com', verify=False)

Please note that this will cause the certificate not to be verified. This will expose your application to security risks, such as man-in-the-middle attacks.

Of course, apply judgment. As mentioned in the comments, this may be acceptable for quick/throwaway applications/scripts, but this should really not go to production software.

If just skipping the certificate check is not acceptable in your particular context, consider the following options, your best option is to set the verify parameter to a string that is the path of the .pem file of the certificate (which you should obtain by some sort of secure means).

So, as of version 2.0, the verify parameter accepts the following values, with their respective semantics:

  • True: causes the certificate to validated against the library's own trusted certificate authorities (Note: you can see which root certificates (RCs) Requests uses via the Certifi library, a trust database of RCs extracted from Requests: Certifi - Trust Database for Humans).

  • False: bypasses certificate validation completely.

  • Path to a CA_BUNDLE file for Requests to use to validate the certificates.

Source: Requests - SSL Cert Verification

Also take a look at the cert parameter on the same page.

Answer from Rafael Almeida on Stack Overflow
Top answer
1 of 16
723

The problem you are having is caused by an untrusted SSL certificate.

Like dirk mentioned in a previous comment, the quickest fix is setting verify=False:

requests.get('https://example.com', verify=False)

Please note that this will cause the certificate not to be verified. This will expose your application to security risks, such as man-in-the-middle attacks.

Of course, apply judgment. As mentioned in the comments, this may be acceptable for quick/throwaway applications/scripts, but this should really not go to production software.

If just skipping the certificate check is not acceptable in your particular context, consider the following options, your best option is to set the verify parameter to a string that is the path of the .pem file of the certificate (which you should obtain by some sort of secure means).

So, as of version 2.0, the verify parameter accepts the following values, with their respective semantics:

  • True: causes the certificate to validated against the library's own trusted certificate authorities (Note: you can see which root certificates (RCs) Requests uses via the Certifi library, a trust database of RCs extracted from Requests: Certifi - Trust Database for Humans).

  • False: bypasses certificate validation completely.

  • Path to a CA_BUNDLE file for Requests to use to validate the certificates.

Source: Requests - SSL Cert Verification

Also take a look at the cert parameter on the same page.

2 of 16
142

From Requests' documentation on SSL verification:

Requests can verify SSL certificates for HTTPS requests, just like a web browser. To check a host’s SSL certificate, you can use the verify argument (for example, interactively):

requests.get('https://kennethreitz.com', verify=True)

If you don't want to verify your SSL certificate, make verify=False

🌐
Medium
medium.com › @dpzhcmy › python-macos-and-certificate-verify-errors-when-making-http-requests-f923a178e4d5
Python, MacOS and Certificate Verify Errors when making HTTP requests | by Sami Kohvakka | Medium
July 31, 2024 - As of Python 3.11.9, additional installation steps are still required on MacOS to ensure that web requests from python do not throw certificate verify errors. The Official Python Installer is kind enough to remind about installing SSL certificates first on the welcome page and then on the Read ...
Discussions

macos - Mac OSX python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) - Stack Overflow
Zscaler (on MacOS) was causing my Python api calls to fail with SSL error · #!/usr/bin/env python3 """ Install corporate SSL certificates (Zscaler) to Python's certifi bundle. This script solves SSL certificate verification errors when behind a corporate proxy that performs SSL inspection ... More on stackoverflow.com
🌐 stackoverflow.com
How to fix ssl.SSLCertVerificationError: … - Apple Community
How to fix ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] More on discussions.apple.com
🌐 discussions.apple.com
macos - Python requests throwing SSL errors - Stack Overflow
I have just installed requests on a Mac OSX 10.8.5. My first attempt at doing requests.get failed on missing certificate: SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed · The thread above says to look for /Library/Frameworks/Python... More on stackoverflow.com
🌐 stackoverflow.com
Python API SDK SSL: CERTIFICATE_VERIFY_FAILED Error
I am running into this error trying to connect smartsheet api via python sdk and getting this error on a mac book pro: smartsheet.exceptions.HttpError: (SSLError(MaxRetryError("HTTPSConnectionPool(host='api.smartsheet.com', port=443): Max retries exceeded with url: /2.0/sheets?pageSize=300... More on community.smartsheet.com
🌐 community.smartsheet.com
August 31, 2022
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
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
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
🌐
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 - Some enterprise environments perform SSL inspection using internal certificates. These often trigger verification errors because Python doesn’t recognize the internal CA. Using an outdated version of Python or OpenSSL can cause compatibility issues with newer TLS configurations. Let’s walk through the most effective ways to fix this error in a safe, scalable, and security-conscious way. Python’s requests library depends on the certifi package to provide a valid set of root CA certificates.
🌐
SSLInsights
sslinsights.com › home › wiki › how to fix ssl certificate_verify_failed error in python
Fix Python SSL CERTIFICATE_VERIFY_FAILED Error in 2026
3 weeks ago - 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 ...
🌐
Apple Community
discussions.apple.com › thread › 254873715
How to fix ssl.SSLCertVerificationError: … - Apple Community
I'm running a Python script that uses urllib3 to retrieve space weather data from the file, SpaceWeather-v1.2.txt, from https://ftp.agi.com/pub/DynamicEarthData/. This script has been working for some time until most recently. I'm now getting an error message: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129) I'm running on a MacPro (2019) under Mac OS X Ventura (13.3.1).
Find elsewhere
Top answer
1 of 1
9

Notice that you're using HTTPS. As mentioned in the Requests manual

To check a host’s SSL certificate, you can use the verify argument [...] By default, verify is set to True

Here are few ways to fix that:

Update OpenSSL (probably will solve your problem)

Taken from here:

If you encounter one of the following errors:

error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm
error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm
The software you are using might be compiled with a version too old of OpenSSL that does not take certificates signed with sha256WithRSAEncryption into account.

It requires at least OpenSSL 0.9.8o for a total management of SHA256. OpenSSl 0.9.7m only assures a partial management, for server mode only.

Check your openssl version by

openssl version
OpenSSL 1.0.1k-fips 8 Jan 2015

If you have a smaller version than OpenSSL0.9.8o, you have to update its version (OS X):

brew update
brew install openssl
brew link --force openssl

If that doesn't work, try this way:

brew uninstall openssl
rm -rf /usr/local/openssl
brew install openssl
  • there's an issue with openssl installed before OS X 10.10.3 and reinstalling it fixes it
  • these command lines will uninstall openssl, remove its folder from your hard-disk and install it again (the updated version)

Install certifi

Taken from here

By default Requests bundles a set of root CAs that it trusts, sourced from the Mozilla trust store. However, these are only updated once for each Requests version. This means that if you pin a Requests version your certificates can become extremely out of date.

From Requests version 2.4.0 onwards, Requests will attempt to use certificates from certifi if it is present on the system. This allows for users to update their trusted certificates without having to change the code that runs on their system.

For the sake of security we recommend upgrading certifi frequently!

In other word, try to install certifi, if you have Request 2.4.0 or newer:

pip install certifi

Hopefully, this will fix the problem.

Use different version of OpenSSL and Requests

Looking into it using Google, I have found that there is a problem with OpenSSL in Python 2:

  • https://github.com/docker/docker-py/issues/465#issuecomment-76520363
  • https://github.com/Homebrew/homebrew/issues/38226
  • https://github.com/docker/compose/issues/1484

However, I am using Python 2.7.6, Requests 2.2.1 and OpenSSL 1.0.1f 6 Jan 2014 and everything runs correctly.

Pass the certificate

In other cases, you may need to tell requests.get the path to the certificate file, if the host's certificate was signed by you.

requests.get("https://api.github.com/events", verify=True, cert=['/path/to/my/ca.crt'])

Set the verify argument to False (NOT RECOMMENDED!)

In case you want to avoid the certificate verification, you have to pass verify=False to the request.get method.

python -c 'import requests; requests.get("https://api.github.com/events", verify=False)'

or from script.py file:

import requests
res = requests.get("https://api.github.com/events", verify=False)
print res

terminal:

$ python script.py
<Response [200]>

Important: Very bad idea; You can be MITM attacked, which is a critical security vulnerability.

🌐
DEV Community
dev.to › mochafreddo › solving-ssl-certificate-verification-issues-with-pip-on-macos-4ahp
Solving SSL Certificate Verification Issues with pip on macOS - DEV Community
March 25, 2025 - # Add to your ~/.zshrc or ~/.bash_profile export SSL_CERT_FILE=/Users/username/.pyenv/versions/3.9.0/lib/python3.9/site-packages/certifi/cacert.pem export REQUESTS_CA_BUNDLE=/Users/username/.pyenv/versions/3.9.0/lib/python3.9/site-packages/certifi/cacert.pem
🌐
Smartsheet Community
community.smartsheet.com › home › get help › api & developers
Python API SDK SSL: CERTIFICATE_VERIFY_FAILED Error - Smartsheet Community
August 31, 2022 - I am running into this error trying to connect smartsheet api via python sdk and getting this error on a mac book pro: smartsheet.exceptions.HttpError: (SSLError(MaxRetryError("HTTPSConnectionPool(host='api.smartsheet.com', port=443): Max retries exceeded with url: /2.0/sheets?pageSize=300&includeAll=False (Caused by…
Top answer
1 of 4
27

TL;DR

The remote website seems to be the problem, not Python. There is likely no fix for this other than to fix the website.

Longer Explanation

The website/server your are dealing with is apparently configured incorrectly. This has nothing directly to do with Python. That said, you can ignore any certificate errors with e.g.:

r = requests.get(url=URL, params=PARAMS, verify=False)

or you can otherwise try to point Python at the missing certificates (as pointed out by @dave_thompson_085 in the comments).

However, this is unlikely to do any good as the server then apparently responds with a 500: Internal Server Error (verified with curl) and a Content-Length: 0, which would seem to indicate an error in the processing of api.php itself (i.e. there is no JSON to process anyway).

2 of 4
4

If you are working within a corporate environment that decrypts your traffic, or possibly proxy servers as part of a VPN, then I have found that the certifi library fails to include the certificate for the decryption server in the certificate package. This leaves you with only 1 good solution, 1 mediocre solution, and 1 bad solution. The bad solution is to not verify the certificates. The mediocre solution is to ask your IT department to whitelist the website you are trying to contact, but you will have to ask them over and over again for every new website you try to contact.

There is a pretty good article on this issue by David Tippet at the following link. https://levelup.gitconnected.com/fixing-your-ssl-verify-errors-in-python-71c2201db4b2

So, what is the good solution? You will have to start by finding someone in your IT department who can give you the URL or IP address for your SSL decryption server, or you can ask them to give you the .pem file in a base64 format for the server. This is a clear text human readable file, and looks something like this:

Certificate example

It will have a 7 lines starting with a comment #, a line that says -----BEGIN CERTIFICATE-----, and a line that ends as -----END CERTIFICATE-----.

Open up your python environment and check to see if you have certifi with the command:

import certifi

Then find out where the chain of certificates is on your computer that Python is using with

certifi.where()

Navigate to the file path returned by certifi.where() and make a copy of that file in case you break something. Mine was located here:

'C:\Users\user_name\Anaconda3\envs\gispy\lib\site-packages\certifi\cacert.pem'

Open up that .txt file and copy and paste the entire certificate for your proxy/decryption server to the end of the cacert.pem file. Now your requests call should work.

🌐
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
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate. We will have several ways to fix this issue in this article. We will skip the SS certificate check in the first three solutions. For the fourth solution, we are going to install the latest CA certificate from certifi. Common Quick Fixes for All OS : 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.
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!

🌐
ScrapingBee
scrapingbee.com › webscraping-questions › requests › how-to-fix-ssl-error-in-python-requests
How to fix SSLError in Python requests? | ScrapingBee
The easiest way to fix this issue is to disable SSL verification for that particular web address by passing in verify=False as an argument to the method calls. Just make sure you are not sending any ...
🌐
Meraki Community
community.meraki.com › t5 › Developers-APIs › SSL-error-in-python › m-p › 186312
Solved: Re: SSL error in python - The Meraki Community
February 28, 2023 - On mac, when you install python, the is a exe named: "Install Certificates.command: in the /Application/Python 3.12/ After executing it, it fixed the issue. No need to chaneg the meraki script. ... The error message CERTIFICATE_VERIFY_FAILED that you are facing while making API calls via Python is a type of standard error that users using a Python environment usually face. The error occurs when making HTTPS requests using the requests module in Python.
🌐
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 ...
🌐
Reddit
reddit.com › r/learnpython › ssl certificate error while using a python virtual environment on macos
r/learnpython on Reddit: SSL certificate error while using a python virtual environment on macos
April 20, 2024 -

Ive been getting this error while working with the "pytube" module:
An error occurred: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

Ive seen similar issues online where the solution was to upgrade certifi with pip. I did that and I still have the issue.

Im on macos 14.2.1 with the m1 chip

🌐
Esri Community
community.esri.com › t5 › python-questions › solving-ssl-errors-in-python-requests › td-p › 1124005
Solving SSL Errors in Python Requests - Esri Community
February 12, 2025 - My machine could now perform a web request through Python without throwing an SSL error. If you're having this same issue, you can most likely do an uninstall of ArcGIS Pro, then make sure to delete the certificate in the location indicated by the requests.certs.where() function before re-installing pro.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-python-requests-sslerror
How to Fix Python Requests SSLError? - GeeksforGeeks
July 23, 2025 - If the certificate path is invalid or there are issues with the certificate, we would get SSLError. We can disable SSL verification by setting verify=False in our requests call.