question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeError: label empty or too long

See original GitHub issue

I’m getting this error:

/lib/python3.6/encodings/idna.py", line 165, in encode
    raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long

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

Traceback (most recent call last):
  File "cloudfail.py", line 266, in <module>
    subdomain_scan(args.target)
  File "cloudfail.py", line 167, in subdomain_scan
    target_http = requests.get("http://"+subdomain)
  File "/tmp/env/lib/python3.6/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/tmp/env/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/tmp/env/lib/python3.6/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/tmp/env/lib/python3.6/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/tmp/env/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/tmp/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/tmp/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/tmp/env/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/tmp/env/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/tmp/env/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 743, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)```

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
shellocommented, Jun 22, 2017

I also saw this error with the default data files from commit 125169c.

It turns out it fails when trying to request m..<target> (an invalid address, notice the two periods with an empty string between them). The m. entry is in the data/subdomains.txt file (line 1275), and as of that commit it’s the only entry ending in a period.

0reactions
m0rtemcommented, Jun 24, 2017

This should now be resolved as of commit a9ef9dc95e972ed7992b7db54fd1abd1406f6349

Read more comments on GitHub >

github_iconTop Results From Across the Web

encoding with 'idna' codec failed (UnicodeError: label empty ...
It seems this is an issue from the socket module. It fails when the URL exceeds 64 characters. This is still an open...
Read more >
encoding with 'idna' codec failed (UnicodeError: label empty ...
Are you able to provide the exact python 2.7 version, build and platform that is exhibiting the UnicodeError: label empty or too long...
Read more >
encoding with 'idna' codec failed (UnicodeError: label empty ...
Unable to open anki app on Win10 "UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)".
Read more >
encoding with 'idna' codec failed (UnicodeError: label empty ...
Python requests - encoding with 'idna' codec failed (UnicodeError: label empty or too long) error. Last Update : 2022-06-27 10:04 am.
Read more >
Unicode error: label empty or too long - Python - Bytes
I only put the name of the project, the name of the author and the version, the rest is by default. I dont...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found