getaddrinfo error due to proxy settings



>>> import urllib2
>>>
>>> data = urllib2.urlopen('http://www.google.com')
Traceback (most recent call last):
File "", line 1, in ?
File "C:\Python24\lib\urllib2.py", line 130, in urlopen
return _opener.open(url, data)
File "C:\Python24\lib\urllib2.py", line 358, in open
response = self._open(req, data)
File "C:\Python24\lib\urllib2.py", line 376, in _open
'_open', req)
File "C:\Python24\lib\urllib2.py", line 337, in _call_chain
result = func(*args)
File "C:\Python24\lib\urllib2.py", line 1021, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python24\lib\urllib2.py", line 996, in do_open
raise URLError(err)
URLError:
>>> import socket
>>> print socket.gethostname()
WXP-GQ86K1S
>>> print socket.gethostbyname(socket.gethostname())
121.241.134.194




This was really weird. I was thinking if that was a problem with the network or my machine. Tried on a different Linux machine and found it worked properly.

See the documentation for urllib.urlopen:

"""
In a Windows environment, if no proxy environment variables are set,
proxy settings are obtained from the registry's Internet Settings
section.
"""
Remove Proxy configuration under IE and try again
(don't use Ie anymore ;0)

Yes, that was the issue. Reset the proxy settings in the IE and found it working again. Is it a good idea to take the environment settings from the registry?
- If we are taking the settings from the registry, Should not the active browser ( firefox) update the registry settings? should it depend on IE only?

No comments: