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.

socket.getaddrinfo appears to be completely broken, all name resolutions fail

See original GitHub issue

Versions

  • Python: python3crystax (app), python 3 on host for building
  • OS: Ubuntu in docker for building, android 7 for test
  • Kivy: not used
  • Cython: most likely not relevant (can check if it is)

Description

Name resolution with socket.getaddrinfo just seems to plain not work, here is what I get for google.com (while nslookup google.com in termux or just browsing google.com in the web browser works fine):

11-07 03:17:28.760 30786 30818 I python  : Traceback (most recent call last):
11-07 03:17:28.760 30786 30818 I python  :   File "/mnt/expand/50b713c2-bef0-4226-aea1-000678d55d07/user/0/com.example.app/files/app/crystax_python/site-packages/nettools/__init__.py", line 59, in dns_lookup_multitarget
11-07 03:17:28.761 30786 30818 I python  :     name, None, socket.AF_INET6)
11-07 03:17:28.761 30786 30818 I python  :   File "/mnt/expand/50b713c2-bef0-4226-aea1-000678d55d07/user/0/com.example.app/files/app/crystax_python/stdlib.zip/socket.py", line 743, in getaddrinfo
11-07 03:17:28.761 30786 30818 I python  :     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
11-07 03:17:28.761 30786 30818 I python  : socket.gaierror: [Errno 7] No address associated with hostname
11-07 03:17:28.761 30786 30818 I python  : 
11-07 03:17:28.761 30786 30818 I python  : During handling of the above exception, another exception occurred:
11-07 03:17:28.761 30786 30818 I python  : 
11-07 03:17:28.761 30786 30818 I python  : Traceback (most recent call last):
11-07 03:17:28.761 30786 30818 I python  :   File "<console>", line 1, in <module>
11-07 03:17:28.761 30786 30818 I python  :   File "/mnt/expand/50b713c2-bef0-4226-aea1-000678d55d07/user/0/com.example.app/files/app/crystax_python/site-packages/nettools/__init__.py", line 78, in dns_lookup
11-07 03:17:28.761 30786 30818 I python  :     raise last_error
11-07 03:17:28.762 30786 30818 I python  :   File "/mnt/expand/50b713c2-bef0-4226-aea1-000678d55d07/user/0/com.example.app/files/app/crystax_python/site-packages/nettools/__init__.py", line 66, in dns_lookup_multitarget
11-07 03:17:28.762 30786 30818 I python  :     name, None, socket.AF_INET)
11-07 03:17:28.762 30786 30818 I python  :   File "/mnt/expand/50b713c2-bef0-4226-aea1-000678d55d07/user/0/com.example.app/files/app/crystax_python/stdlib.zip/socket.py", line 743, in getaddrinfo
11-07 03:17:28.762 30786 30818 I python  :     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
11-07 03:17:28.762 30786 30818 I python  : socket.gaierror: [Errno 7] No address associated with hostname

The same code works fine on desktop (with python 3 on GNU/Linux and Microsoft Windows). Please note I wrote nettools so I’m not using some odd third-party wrapper that may do whatever instead of just looking up the hostname - all the function I wrote does is automatically try AF_INET6 first and fall back to AF_INET if that doesn’t work (as should be easy to reconstruct from the backtrace).

I tested this on latest master with the ctypes fix pull request on top ( #1433 ) which shouldn’t affect name resolution.

buildozer.spec

not used, I build with a p4a one liner

Logs

see backtrace above

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
ghostcommented, Nov 7, 2018

😆 yup, was internet permission

0reactions
Adistar964commented, Oct 4, 2020

how to give android internet permissions(I gave it, but it does not show up)

Read more comments on GitHub >

github_iconTop Results From Across the Web

socket.gethostbyname, getaddrinfo etc broken on MacOS 10.12
Currently I can't use socket to resolve host names to IP addresses. This is something critical to mine as well as other applications...
Read more >
How to Resolve the "Temporary failure in name resolution" Error
The "Temporary failure in name resolution" error appears due to bad system configuration. This article shows how to troubleshoot and fix it.
Read more >
573904 – getaddrinfo failing with 'Temporary failure in name ...
They return the DNS error message 'Temporary failure in name resolution'. But doing a nslookup/dig of the host returns the IP address successfully....
Read more >
I get this error:' socket.gaierror: [Errno 11001] getaddrinfo ...
getaddrinfo failed is an error that means the OS couldn't resolve an IP address for a DNS name.
Read more >
Windows Sockets Error Codes (Winsock2.h) - Win32 apps
This is usually a temporary error during host name resolution and means that the local server did not receive a response from an...
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