Re the EADDRNOTAVAIL from socket.connect(),<p>If you&#x27;re connecting to 127.0.0.1:8080, then each connection from 127.0.0.1 is going to be assigned an ephemeral TCP source port. There are only a finite number of such ports available, on the order of ~30-50k, which limits the number of connections from a single address to a specific endpoint.<p>If you&#x27;re doing 100k TCP connections with 1k concurrent conections, it&#x27;s feasible that you&#x27;ll run into those limits, with TCP connections hanging around in some TIME_WAIT state after close().<p>Not that this would be a documented errno for connect(), but it&#x27;s the interpretation that makes sense..<p><a href="http:&#x2F;&#x2F;www.toptip.ca&#x2F;2010&#x2F;02&#x2F;linux-eaddrnotavail-address-not.html" rel="nofollow">http:&#x2F;&#x2F;www.toptip.ca&#x2F;2010&#x2F;02&#x2F;linux-eaddrnotavail-address-not...</a>
<a href="http:&#x2F;&#x2F;lxr.free-electrons.com&#x2F;source&#x2F;net&#x2F;ipv4&#x2F;inet_hashtables.c?v=4.4#L572" rel="nofollow">http:&#x2F;&#x2F;lxr.free-electrons.com&#x2F;source&#x2F;net&#x2F;ipv4&#x2F;inet_hashtable...</a>