The error means requests could not trust the certificate the server sent. Read the text after CERTIFICATE_VERIFY_FAILED, because it names the cause. Then point verify at the right CA file, fix the server chain, or use your system store. We reproduced each case on a local test server and show the output below.
Definition: SSL: CERTIFICATE_VERIFY_FAILED is the SSLError that requests raises when its certificate check fails. The check covers the chain of trust, the hostname and the dates.
Why Does Requests Fail When Your Browser Works?
Requests does not read your operating system's certificate store. It uses the CA list from the certifi package, which the requests documentation describes. A browser uses the system store instead. A private or company CA that your system trusts is therefore unknown to requests.
We tested it with SSL_CERT_FILE pointing at our test CA. The urllib module connected, but requests still failed.
What Do the Different Error Messages Mean?
The text after CERTIFICATE_VERIFY_FAILED tells you the cause. We built four broken servers and read the exact message from each. Match your message to the table, then jump to the fix that fits. Do not start with verify=False, because it hides the real problem.
| Message from requests | Meaning | Fix |
|---|---|---|
| unable to get local issuer certificate | Requests does not trust the issuer, or the server sent no intermediate | Pass the CA file in verify, or fix the server chain |
| self-signed certificate | The server certificate signed itself | Trust that certificate file, or use a CA-issued one |
| Hostname mismatch, certificate is not valid for 'localhost' | The name in the URL is not in the certificate | Use a name the certificate lists, or reissue it |
| certificate has expired | The certificate's end date has passed | Renew the certificate on the server |

Three of the four messages, taken from our local test servers.
If you hit the self-signed case, read our fix for the self-signed certificate in certificate chain error.
How Do You Trust a Private CA with the Verify Parameter?
Pass the path of the CA file as verify. Requests then checks the server against that file instead of certifi. In our test, a plain call failed and the same call with verify="ca.pem" returned status 200. The file must hold the CA that signed the server certificate.
requests.get("https://localhost:9441", verify="ca.pem")
The same URL fails by default and returns 200 with verify set to the CA file.
You can also set s.verify = "ca.pem" on a Session, which the requests docs show. A directory also works, if you processed it with c_rehash.
How Do You Fix a Missing Intermediate Certificate?
Fix it on the server, not in your code. If the server sends only its own certificate, clients cannot link it to the root. We tested a server that sent only the leaf, and requests failed with the local issuer error. The root was in verify.
- Server sends the leaf only, root in verify: it failed.
- Server sends the leaf and the intermediate, root in verify: it returned 200.
- Server sends the leaf only, root and intermediate in verify: it returned 200.
The second row is the right fix, because every client then works. For a full walk-through, see our guide to unable to get local issuer certificate in Python.
How Do You See Which Certificates the Server Really Sends?
Run openssl s_client -connect host:port -showcerts and count the certificates in the chain. A healthy server lists its own certificate and each intermediate. On our broken test server, OpenSSL listed only depth 0 and returned verify code 21. On the fixed server, it listed two certificates and code 0.

One certificate in the chain means the intermediate is missing.
What If the Server Asks for a Client Certificate?
That is a different setting. Server verification uses verify, while a client certificate uses the cert parameter. You pass one file holding the key and certificate, or a tuple of two files. The requests docs warn that the private key must be unencrypted. We did not test client certificates here.
How Do You Set the CA File for a Whole Script?
Set the REQUESTS_CA_BUNDLE environment variable to your CA file. Requests uses CURL_CA_BUNDLE as a fallback, as its docs explain. Both worked in our test with no code change. Watch for one trap: these variables beat the verify value you set on a Session.

Both variables work, and the variable overrides Session.verify.
We set the variable to a wrong file and s.verify to the right one, so the call failed. A per-request verify= still worked, so check your shell for leftover variables.
How Do You Use the System Certificate Store with Truststore?
Install truststore and call truststore.inject_into_ssl() before you import requests. Requests then verifies against the operating system store, which is the usual fix behind a company proxy. The truststore documentation says it needs Python 3.10 or later and suits scripts, not libraries.
import truststore
truststore.inject_into_ssl()
import requestsOn Linux, truststore reads the OpenSSL defaults, so with SSL_CERT_FILE set to our test CA, requests returned 200. Without it, the call failed, and we could not edit a real Windows or macOS store here.
When Should You Update Certifi?
Update certifi when public sites fail on an old machine, because its CA list may be out of date. Run pip install --upgrade certifi. Then python -m certifi prints the bundle path that requests uses. Our test machine showed a path inside site-packages.
- Check the path with python -m certifi.
- Upgrade with pip install --upgrade certifi.
- On macOS python.org installs, the Install Certificates.command script in the Python folder refreshes certificates. We did not test macOS.
Missing certificates can also follow a fresh Python install, so check the version you run.
What Is a Safe Setup for Production Code?
Keep verification on and make the trust source explicit. So choose one of three routes, based on where the certificate comes from. Public sites need an up-to-date certifi. Private servers also need a CA file. Company networks then need the system store through truststore.
- Public APIs: keep the default and update certifi.
- Private services: ship the CA file and pass it in verify.
- Company proxy: use truststore, or ask IT for the proxy root and add it to your CA file.
- Never commit verify=False.
Is It Ever Safe to Use verify=False?
Only for local testing against a server you control. The setting makes requests accept any certificate, including wrong hostnames and expired dates. An attacker on the network can then read your traffic. Requests prints an InsecureRequestWarning, which we saw in our run.

verify=False works, and requests warns that the request is unverified.
Fix the trust problem instead of silencing that warning. Our guide to fixing certificate verify failed errors in Python covers pip and corporate proxies in depth.
How can You Check the Server Before You Change Code?
Test the server's chain with a checker before you edit any Python. A missing intermediate, a wrong hostname or an expired date all show up there. Our free SSL checker reports each of them. Fix the server when the checker finds a problem, because code changes only hide it.
Frequently Asked Questions
What does SSL: CERTIFICATE_VERIFY_FAILED mean in Python requests?
Requests could not verify the server certificate. The text after the error names the cause. Common causes are an unknown issuer, a self-signed certificate, a hostname mismatch or an expired date.
How do I fix certificate verify failed in requests?
Find the cause from the message. Then pass the right CA file in verify, fix the server's certificate chain, or use truststore for the system store.
How do I add a certificate to Python requests?
Pass the path of the CA file as the verify parameter, or set REQUESTS_CA_BUNDLE to that path.
How do I disable SSL verification in Python requests?
Set verify=False. Use it only for local testing, because it accepts any certificate and exposes you to man-in-the-middle attacks.
Why does requests fail but curl or my browser works?
Requests uses the certifi bundle, while curl and browsers often use the system store. A private CA trusted by the system can be unknown to requests.
Does updating certifi fix the error?
It fixes cases where the bundle is out of date. It does not fix a self-signed certificate, a hostname mismatch or a missing intermediate.
Does REQUESTS_CA_BUNDLE override Session.verify?
In our test, yes. The variable won, and a per-request verify value still worked.
