How to fix ReadTimeout error in Python requests?

ReadTimeout occurs when the website you are trying to connect to doesn't send back data in time. You can simulate this error for a website by using a custom read timeout in your request.get() call:

import requests

# Timeout is in seconds
connect_timeout = 5
read_timeout = 0.1
response = requests.get("https://scrapingbee.com/", timeout=(connect_timeout, read_timeout))

If you are sure your IP is not being blocked by the website and the website just needs more time before returning data, then you can fix this error by increasing the read timeout:

import requests

connect_timeout = 6
read_timeout = 10
response = requests.get("https://scrapingbee.com/", timeout=(connect_timeout, read_timeout))

Related Requests web scraping questions: