import requests url = 'http://httpbin.org/basic-auth/user/pass' try: response = requests.get(url, timeout=0.1) except Exception as e: print(e) print(response.status_code)