Skip to content Skip to sidebar Skip to footer

Python: Requests.exceptions.connectionerror - Only One Usage Of Each Socket Address (protocol/network Address/port) Is Normally Permitted

I'm sending GET requests to a json API inside a loop, like this: import requests for var in my_range: url = f'http://127.0.0.1:8081/api/my_query/{var}' response = requ

Solution 1:

Thanks to James Lin and Frank Yellin for the tip!

import requests

with requests.Session() as s:
    forvarin my_range:
        url = f"http://127.0.0.1:8081/api/my_query/{var}"
            response = s.get(url=url)
            if response.status_code == 200:
                < do stuff >

Problem solved

Post a Comment for "Python: Requests.exceptions.connectionerror - Only One Usage Of Each Socket Address (protocol/network Address/port) Is Normally Permitted"