Python Requests Error: Max retries exceeded with url

Use the requests library to request url, this error will occur, the reason is:

The server is overloaded, and no more links can be established. There are 4 possibilities:

  1. Too many http connections are not closed.
  2. The machine’s memory is insufficient.
  3. Another possibility is that the IP is blocked by the target website due to the high request frequency
  4. The requested URL address is wrong

Solution:

1. increase the number of retry connections
requests.adapters.DEFAULT_RETRIES = 5

2. close redundant connections
requests uses the urllib3 library, the default http connection is keep-alive, requests set False to close.
Operation method:
s = requests.session()
s.keep_alive = False

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *