Failed to establish a new connection: [Errno 110] Connection timed out

Hello,

My code fetching data from the Twitch API used to work for weeks without any issues, but recently it crashes everyday with the following message :

HTTPSConnectionPool(host='api.twitch.tv', port=443): Max retries exceeded with url: /helix/users?id=685338800&id=685338801 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f24ba8ab908>: Failed to establish a new connection: [Errno 110] Connection timed out'))

I have a retry system but it seems that it failed so many times on the same request that the program decided to exit().

I’m wondering what could be the cause ? I’ve seen on some website that it may be some sort of web-scraping security, however I have been strictly following the API ratelimits.

Hope someone can help :frowning:

I’m using a netcup(german host) server.

To note that the error doesn’t appear 100% of the time. When I start the program, it works for about a day, then it stops working. (Sometime, after X retries, things seem to get unlocked and it works, only to re-fail a few requests later, until at some point it passes the threshold and exit() the program)

I’m using Python and the Requests library.

You are having DNS or name resoutions issues or route issues between your server and/or the API

This is either a your server, your provider or a fastly issue (faslty being the CDN in front of the API)

Theres no simple fix as it’s not a twitch issue and fiddiling with your servers settings can result in other issues

Such a thing can and will happen with any API not just Twitch

Thank your for the quick reply ! I will try to ask netcup if they have any issues with their servers. And in the meantime I will change from Google DNS to Cloudflare DNS, maybe it works !

Not related but still: You said you are using the requests library, but depending on your project you may want to consider using aiohttp instead, as requests is blocking and aiohttp isn’t.

As I am also a Netcup customer, i know that their default DNS Server for VPS/Root Servers are usually quite reliable, but my old Windows Server occasionally has hiccups in the evening hours with internet connectivity.

If using a different DNS Server does not solve the issue from reappearing, do note down the times of when you’re having troublr - perchance we can combine our data to make a proper report for their support team to look into!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.