<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ATTENTION: socket.getaddrinfo() resolves to randon false IP Addresses]]></title><description><![CDATA[<p dir="auto">Pycom Management and Technical Personnel,</p>
<p dir="auto">I see this problem posted multiple times in the LoPy forum with no guidance or resolution provided back to your customers &amp; users. So I'm creating another one hoping to get some attention.</p>
<p dir="auto">This is a fundamental feature of your product that you provide example code for and should work correctly.</p>
<p dir="auto">Why is this happening?</p>
<p dir="auto">Is this a BUG or a CONFIG ISSUE?</p>
<p dir="auto">PROBLEM: socket.getaddrinfo() resolves incorrectly, giving random incorrect IPv4 IP address, using either of my DNS servers. Tried with URL's <a href="http://micropython.org" target="_blank" rel="noopener noreferrer nofollow">micropython.org</a> &amp; <a href="http://google.com" target="_blank" rel="noopener noreferrer nofollow">google.com</a></p>
<pre><code class="language-&gt;&gt;&gt;">(sysname='LoPy', nodename='LoPy', release='1.0.0.b1', version='v1.8.6-251-g2fb950d on 2016-12-16', machine='LoPy with ESP32')
&gt;&gt;&gt; wlan.ifconfig()
('10.0.0.36', '255.255.255.0', '10.0.0.1', '75.75.75.75')
&gt;&gt;&gt; import socket
&gt;&gt;&gt; addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
&gt;&gt;&gt; s = socket.socket()
&gt;&gt;&gt; s.connect(addr)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
OSError: [Errno 113] EHOSTUNREACH
&gt;&gt;&gt; print(addr)
('94.137.14.128', 80)&lt;-------THIS IS INCORRECT IP ADDRESS FOR micropython.org

----------------------------------------------------------------------------------

&gt;&gt;&gt; wlan.ifconfig(config=('10.0.0.36', '255.255.255.0', '10.0.0.1', '76.76.76.76'))
&gt;&gt;&gt; wlan.ifconfig()
('10.0.0.36', '255.255.255.0', '10.0.0.1', '76.76.76.76')
&gt;&gt;&gt; addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
&gt;&gt;&gt; s = socket.socket()
&gt;&gt;&gt; s.connect(addr)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
OSError: [Errno 113] EHOSTUNREACH
&gt;&gt;&gt; print(addr)
('156.16.8.3', 80)&lt;-------THIS IS INCORRECT IP ADDRESS FOR micropython.org
</code></pre>
<p dir="auto">HOWEVER: When I use the same code on my Ubuntu 16.04 / Python on the same WIFI LAN it resolves the IP address successfully.</p>
<pre><code>rdixey@RND-SP3:~$ nmcli device show wlp1s0 | grep IP4.DNS
IP4.DNS[1]:                             75.75.75.75
IP4.DNS[2]:                             75.75.76.76
rdixey@RND-SP3:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import socket
&gt;&gt;&gt; addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
&gt;&gt;&gt; s = socket.socket()
&gt;&gt;&gt; s.connect(addr)
&gt;&gt;&gt; print(addr)
('176.58.119.26', 80)&lt;-------THIS IS CORRECT IP ADDRESS FOR micropython.org
</code></pre>
]]></description><link>https://forum.pycom.io/topic/375/attention-socket-getaddrinfo-resolves-to-randon-false-ip-addresses</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 05:05:33 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/375.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Dec 2016 03:12:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ATTENTION: socket.getaddrinfo() resolves to randon false IP Addresses on Sat, 17 Dec 2016 03:12:56 GMT]]></title><description><![CDATA[<p dir="auto">Pycom Management and Technical Personnel,</p>
<p dir="auto">I see this problem posted multiple times in the LoPy forum with no guidance or resolution provided back to your customers &amp; users. So I'm creating another one hoping to get some attention.</p>
<p dir="auto">This is a fundamental feature of your product that you provide example code for and should work correctly.</p>
<p dir="auto">Why is this happening?</p>
<p dir="auto">Is this a BUG or a CONFIG ISSUE?</p>
<p dir="auto">PROBLEM: socket.getaddrinfo() resolves incorrectly, giving random incorrect IPv4 IP address, using either of my DNS servers. Tried with URL's <a href="http://micropython.org" target="_blank" rel="noopener noreferrer nofollow">micropython.org</a> &amp; <a href="http://google.com" target="_blank" rel="noopener noreferrer nofollow">google.com</a></p>
<pre><code class="language-&gt;&gt;&gt;">(sysname='LoPy', nodename='LoPy', release='1.0.0.b1', version='v1.8.6-251-g2fb950d on 2016-12-16', machine='LoPy with ESP32')
&gt;&gt;&gt; wlan.ifconfig()
('10.0.0.36', '255.255.255.0', '10.0.0.1', '75.75.75.75')
&gt;&gt;&gt; import socket
&gt;&gt;&gt; addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
&gt;&gt;&gt; s = socket.socket()
&gt;&gt;&gt; s.connect(addr)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
OSError: [Errno 113] EHOSTUNREACH
&gt;&gt;&gt; print(addr)
('94.137.14.128', 80)&lt;-------THIS IS INCORRECT IP ADDRESS FOR micropython.org

----------------------------------------------------------------------------------

&gt;&gt;&gt; wlan.ifconfig(config=('10.0.0.36', '255.255.255.0', '10.0.0.1', '76.76.76.76'))
&gt;&gt;&gt; wlan.ifconfig()
('10.0.0.36', '255.255.255.0', '10.0.0.1', '76.76.76.76')
&gt;&gt;&gt; addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
&gt;&gt;&gt; s = socket.socket()
&gt;&gt;&gt; s.connect(addr)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
OSError: [Errno 113] EHOSTUNREACH
&gt;&gt;&gt; print(addr)
('156.16.8.3', 80)&lt;-------THIS IS INCORRECT IP ADDRESS FOR micropython.org
</code></pre>
<p dir="auto">HOWEVER: When I use the same code on my Ubuntu 16.04 / Python on the same WIFI LAN it resolves the IP address successfully.</p>
<pre><code>rdixey@RND-SP3:~$ nmcli device show wlp1s0 | grep IP4.DNS
IP4.DNS[1]:                             75.75.75.75
IP4.DNS[2]:                             75.75.76.76
rdixey@RND-SP3:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import socket
&gt;&gt;&gt; addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
&gt;&gt;&gt; s = socket.socket()
&gt;&gt;&gt; s.connect(addr)
&gt;&gt;&gt; print(addr)
('176.58.119.26', 80)&lt;-------THIS IS CORRECT IP ADDRESS FOR micropython.org
</code></pre>
]]></description><link>https://forum.pycom.io/post/2237</link><guid isPermaLink="true">https://forum.pycom.io/post/2237</guid><dc:creator><![CDATA[rdixey]]></dc:creator><pubDate>Sat, 17 Dec 2016 03:12:56 GMT</pubDate></item><item><title><![CDATA[Reply to ATTENTION: socket.getaddrinfo() resolves to randon false IP Addresses on Mon, 19 Dec 2016 15:26:28 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/455">@rdixey</a> this is an issue when using static IP configurations and we are trying to resolve it with Espressif. Are you able to use DHCP in the meantime? Thanks.</p>
<p dir="auto">Cheers,<br />
Daniel</p>
]]></description><link>https://forum.pycom.io/post/2322</link><guid isPermaLink="true">https://forum.pycom.io/post/2322</guid><dc:creator><![CDATA[daniel]]></dc:creator><pubDate>Mon, 19 Dec 2016 15:26:28 GMT</pubDate></item><item><title><![CDATA[Reply to ATTENTION: socket.getaddrinfo() resolves to randon false IP Addresses on Mon, 19 Dec 2016 17:30:50 GMT]]></title><description><![CDATA[<p dir="auto">Daniel, I reconfigured the LoPy and router for DHCP and the socket connection works just fine. I would not have known this without your reply since I did search the forum and did not find this info there. Many Thanks :)</p>
]]></description><link>https://forum.pycom.io/post/2331</link><guid isPermaLink="true">https://forum.pycom.io/post/2331</guid><dc:creator><![CDATA[rdixey]]></dc:creator><pubDate>Mon, 19 Dec 2016 17:30:50 GMT</pubDate></item><item><title><![CDATA[Reply to ATTENTION: socket.getaddrinfo() resolves to randon false IP Addresses on Mon, 19 Dec 2016 17:32:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/455">@rdixey</a> thanks for the feedback. We'll do our best to solve the static IP problem asap.</p>
<p dir="auto">Cheers,<br />
Daniel</p>
]]></description><link>https://forum.pycom.io/post/2332</link><guid isPermaLink="true">https://forum.pycom.io/post/2332</guid><dc:creator><![CDATA[daniel]]></dc:creator><pubDate>Mon, 19 Dec 2016 17:32:52 GMT</pubDate></item><item><title><![CDATA[Reply to ATTENTION: socket.getaddrinfo() resolves to randon false IP Addresses on Mon, 19 Dec 2016 21:52:09 GMT]]></title><description><![CDATA[<p dir="auto">I confirm problem solved by use of the DHCP instead of static parameters in wlan.ifconfig.<br />
If you need a static address it seems that the sequence :<br />
wlan.ifconfig(static parameters) (by example in <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a>)<br />
wlan.ifconfig(dhcp)<br />
wlan.ifconfig(static parameters)<br />
correctly initialize the name resolver (the DNS server must be the same for the static and dhcp config).<br />
tested with 1.0.0b2</p>
]]></description><link>https://forum.pycom.io/post/2345</link><guid isPermaLink="true">https://forum.pycom.io/post/2345</guid><dc:creator><![CDATA[PCA]]></dc:creator><pubDate>Mon, 19 Dec 2016 21:52:09 GMT</pubDate></item></channel></rss>