dpguthrie / yahooquery

Python wrapper for an unofficial Yahoo Finance API
https://yahooquery.dpguthrie.com
MIT License
781 stars 138 forks source link

exception, connectionerror [Errno 11001] getaddrinfo failed #233

Closed SasquatchFace closed 11 months ago

SasquatchFace commented 1 year ago

I have two computers.  One where the "(https://github.com/dpguthrie/yahooquery.git@feat/set-cookie-and-crumb)" version of yahooquery (which I can't find now) is used (I won't have access this pc for a while) and another that I just installed everything from scratch.  The newly installed (all packages are up to date) environment gives me these errors:

Exception has occurred: ConnectionError HTTPSConnectionPool(host='fc.yahoo.com', port=443): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000001ED141B50A0>: Failed to resolve 'fc.yahoo.com' ([Errno 11001] getaddrinfo failed)")) socket.gaierror: [Errno 11001] getaddrinfo failed

The above exception was the direct cause of the following exception:

urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x000001ED141B50A0>: Failed to resolve 'fc.yahoo.com' ([Errno 11001] getaddrinfo failed)

The above exception was the direct cause of the following exception:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='fc.yahoo.com', port=443): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000001ED141B50A0>: Failed to resolve 'fc.yahoo.com' ([Errno 11001] getaddrinfo failed)"))

I use this code to reproduce the error:

    from yahooquery import Ticker

    ticklist = ["ABBV", "JNJ"]
    tickers = Ticker(ticklist, asynchronous=True)
    print(tickers)

Windows 10 Microsoft Edge Version 119.0.2151.44 (Official build) (64-bit) FireFox 119.0 (64-bit) Python 3.12.0 Yahooquery 2.3.3

I'm not entirely certain this is a yahooquery issue, however, I have no clue how to resolve this.

Thanks!

mrmak0030 commented 1 year ago

Have the same issue. URLib3 timeout error from around 1am GMT for Windows 11, YahooQuery 2.3.3. Able to run prior to that time (in Australia] regardless of VPN connection to US or local. VPN location makes no difference now. Python 3.9 -> 3.11 have the same issue.

However same code runs fine on Ubuntu 20.04. No URLLib issues, no timeouts.

######## Update - not YQ or (kinda)Yahoo, but VPN Protocol ##########

Appears to be VPN issue. ExpressVPN Lightway protocols seem to be causing an issue with Yahoo and resulting in the request timeout. VPN off or using ExpressVPN OpenVPN -UDP or TCP works.

gmasse commented 1 year ago

Using NextDNS with the default blocklist Ads & Trackers Blocklist (same issue #235). I added fc.yahoo.com into the allowlist.

SasquatchFace commented 11 months ago

I finally got a chance to dig into this, and got it working again. It turns out it was my router adblock. It just happened to correspond with me setting up a new PC, so I went off on a wild goose chase in that direction. I don't know what changed where to make the adblock not like it (nothing changed with the adblock), but I added fc.yahoo.com to the whitelist and it now works again. Thanks to all who posted and thought about this!

jwcolby54 commented 3 months ago

In my case it was PiHole. I turned it off for 5 minutes and voila.