xword-dl icon indicating copy to clipboard operation
xword-dl copied to clipboard

Connection issues when trying to download by URL

Open chrisl64squares opened this issue 6 months ago • 4 comments

I am using xword-dl extensively and without issues for downloading puzzles from established outlets using their keyword (thank you, btw, for creating and maintaining this outstanding tool!).

However, attempting to download by URL consistently fails due to some kind of connection error. I searched around for info about the errors (as I could figure them out; I toy with code but am not a programmer) and it seems like it might be an error specific to some OSX installations and settings, but none of the fixes that seemed potentially relevant helped.

At any rate, following are my system info and the error I receive using the example puzzle URL from this repository's README file. Please let me know what else I can share that might help, and thanks in advance for your suggestions!

System info

  • M3 MacBook Air
  • macOS 15.5 (24F74)
  • xword-dl 2025.5.8
  • Python 3.13.3
  • pip 25.1.1

I am running xword-dl in a virtual env as recommended.

Because it seems to be mentioned a lot in the context of this error, my hosts file (btw, this error occurs on every network I've used at home, work, and coffeeshop):

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

My hostname is set properly, I believe:

xword-dl_env ❯ scutil --get HostName
localhost

Error message:

xword-dl_env ❯ xword-dl https://rosswordpuzzles.com/2021/01/03/cover-up/
Traceback (most recent call last):
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
        (self._dns_host, self.port),
    ...<2 lines>...
        socket_options=self.socket_options,
    )
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
               ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.3_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/socket.py", line 977, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

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

Traceback (most recent call last):
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    response = self._make_request(
        conn,
    ...<10 lines>...
        **response_kw,
    )
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connectionpool.py", line 488, in _make_request
    raise new_e
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connectionpool.py", line 464, in _make_request
    self._validate_conn(conn)
    ~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connectionpool.py", line 1093, in _validate_conn
    conn.connect()
    ~~~~~~~~~~~~^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connection.py", line 704, in connect
    self.sock = sock = self._new_conn()
                       ~~~~~~~~~~~~~~^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connection.py", line 205, in _new_conn
    raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x10541f610>: Failed to resolve 'pagead2.googlesyndication.com' ([Errno 8] nodename nor servname provided, or not known)

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

Traceback (most recent call last):
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
        method=request.method,
    ...<9 lines>...
        chunked=chunked,
    )
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/connectionpool.py", line 841, in urlopen
    retries = retries.increment(
        method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
    )
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/urllib3/util/retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='pagead2.googlesyndication.com', port=443): Max retries exceeded with url: /pagead/js/adsbygoogle.js (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x10541f610>: Failed to resolve 'pagead2.googlesyndication.com' ([Errno 8] nodename nor servname provided, or not known)"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/bin/xword-dl", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/xword_dl/xword_dl.py", line 259, in main
    puzzle, filename = by_url(args.source, **options)
                       ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/xword_dl/xword_dl.py", line 67, in by_url
    dl, puzzle_url = parse_for_embedded_puzzle(url, **kwargs)
                     ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/xword_dl/xword_dl.py", line 108, in parse_for_embedded_puzzle
    res = requests.get(js_url, headers={'User-Agent':'xword-dl'})
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Users/chris/Library/CloudStorage/Dropbox/word-puzzles/crosswords-acrostics/xword-dl_env/lib/python3.13/site-packages/requests/adapters.py", line 700, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='pagead2.googlesyndication.com', port=443): Max retries exceeded with url: /pagead/js/adsbygoogle.js (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x10541f610>: Failed to resolve 'pagead2.googlesyndication.com' ([Errno 8] nodename nor servname provided, or not known)"))

chrisl64squares avatar Jun 12 '25 15:06 chrisl64squares

Hi Chris! Thanks for the report. I would say this is an xword-dl bug, but it's likely being triggered by something about your configuration.

In particular, at first glance, it looks like it's choking on connections to a Google Ads server, which is probably something embedded on that page and others. xword-dl should ignore failures like that, or report that it was unsuccessful, but it shouldn't crash out like this! (I think it's possible #217 would fix this, in fact.)

I'm curious, do you have any kind of system-wide ad-blocking software in place? Again, I would prefer to fix this on my end but it's possible we can find a workaround in the meantime.

thisisparker avatar Jun 12 '25 16:06 thisisparker

This put me on the right track. I am running Adguard, but that wasn't the problem. It appears (I will test at home as well later today) that the issue was the "Private WiFi Address" in my network settings (which was set to "Rotating"). When I disable that option, xword-dl works fine. I don't recall enabling the option, so perhaps that's the default? But I wouldn't put it past myself to have forgotten enabling it!

I'll test tonight at home as well and let you know here if the issue is, indeed, solved for the moment.

chrisl64squares avatar Jun 12 '25 17:06 chrisl64squares

Looks like that took care of the issue thus far! Perhaps this will help some future OSX users lose a little less hair 😆

chrisl64squares avatar Jun 13 '25 22:06 chrisl64squares

Guess I spoke too soon...the problem reappeared where it was working a few minutes ago. I don't know what is up!

chrisl64squares avatar Jun 13 '25 23:06 chrisl64squares