getaddrinfo failed, what does that mean?
It most likely means the hostname can't be resolved.
import socket
socket.getaddrinfo('localhost', 8080)
If it doesn't work there, it's not going to work in the Bottle example. You can try '127.0.0.1' instead of 'localhost' in case that's the problem.
(python) [Errno 11001] getaddrinfo failed
Well, let’s ask Python what type of exception that is:
#!/usr/bin/env python2.7
import pygeoip
gi = pygeoip.GeoIP('GeoIP.dat')
try:
print gi.country_code_by_name('specificdownload.com')
except Exception, e:
print type(e)
print e
Prints:
$ ./foo.py
<class 'socket.gaierror'>
[Errno 8] nodename nor servname provided, or not known
So we need to catch socket.gaierror
, like so:
#!/usr/bin/env python2.7
import pygeoip
import socket
gi = pygeoip.GeoIP('GeoIP.dat')
try:
print gi.country_code_by_name('specificdownload.com')
except socket.gaierror:
print 'ignoring failed address lookup'
Though there’s still the question of, what the heck is gaierror
? Google turns up the socket.gaierror
documentation, which says,
This exception is raised for address-related errors, for
getaddrinfo()
andgetnameinfo()
So GAI Error = Get Address Info Error.
Related Topics
How to Detect Whether a Python Variable Is a Function
How to Get List of Methods in a Python Class
Is Python Interpreted, or Compiled, or Both
How to Specify the Function Type in My Type Hints
Extending Setuptools Extension to Use Cmake in Setup.Py
How to Get Href Links from HTML Using Python
Beautifulsoup Webscraping Find_All( ): Finding Exact Match
How to Take a Screenshot/Image of a Website Using Python
What Does a Python Process Return Code -9 Mean
Popen.Communicate() Throws Oserror: "[Errno 10] No Child Processes"
Understanding Python Unicode and Linux Terminal
How to Limit Memory Usage Within a Python Process
How to Search Directories and Find Files That Match Regex