How to fix Python requests SSLError?

by scrapecrow Dec 19, 2022

SSLError error is seen when using Python requests module to scrape pages with untrusted SSL certificates.

import requests
response = requests.get("https://example.com/")
# raises: 
# SSLError: HTTPConnectionPool(host='example.com', port=80)...

# we can disable certificate verficiation (note: dangerous as it disables e2e encryption)
response = requests.get("https://example.com/", verify=False)
# or specify certficate file explicitly (.rem)
cert_location = "certificates/example-com-certificate.pem"
response = requests.get("https://example.com/", verify=cert_location)

The SSLError exception is rarely encountered in web scraping but the easiest way to fix it is to simply disable certification verification (verify=False parameter) if no sensitive data is being exchanged.

Note if manual fix is required the SSL certificates requests is using can be found using the requests.certs.where() method:

import requests
print(requests.certs.where())
'/etc/ssl/certs/ca-certificates.crt'  # example on Linux

This value can also be overridden using REQUESTS_CA_BUNDLE environment variable:

$ export REQUESTS_CA_BUNDLE="/etc/ssl/certs/my-certificates.pem" 
$ python -c "import requests;print(requests.certs.where())"
/ets/ssl/certs/my-certificates.pem

Finally, requests is using certifi to handle all SLL certificate-related operations - try updating it: pip install certifi --upgrade

Related Articles

How to Scrape Ticketmaster Event Data

Learn how to scrape Ticketmaster for event data including concerts, venues, dates, and ticket information using Python. Complete guide with code examples and anti-blocking techniques.

PYTHON
SCRAPEGUIDE
BEAUTIFULSOUP
REQUESTS
How to Scrape Ticketmaster Event Data

How to Scrape Mouser.com

Learn how to scrape Mouser.com electronic component data including prices, specifications, and inventory using Python. Complete guide with code examples and anti-blocking techniques.

PYTHON
SCRAPEGUIDE
BEAUTIFULSOUP
REQUESTS
How to Scrape Mouser.com

How to Scrape Zoro.com

Learn how to scrape Zoro.com product data including prices, specifications, and inventory using Python. Complete guide with code examples and anti-blocking techniques.

PYTHON
SCRAPEGUIDE
BEAUTIFULSOUP
REQUESTS
How to Scrape Zoro.com

Guide to Python requests POST method

Discover how to use Python's requests library for POST requests, including JSON, form data, and file uploads, along with response handling tips.

PYTHON
REQUESTS
HTTP
Guide to Python requests POST method

Guide to Python Requests Headers

Our guide to request headers for Python requests library. How to configure and what do they mean.

PYTHON
REQUESTS
HTTP
Guide to Python Requests Headers

How to Scrape YouTube in 2025

Learn how to scrape YouTube, channel, video, and comment data using Python directly in JSON.

SCRAPEGUIDE
PYTHON
HIDDEN-API
How to Scrape YouTube in 2025