I have a python web-scraper script that has been running fine for months. It uses urllib2 to access remote URLs, submit data, capture results, etc.
Suddenly yesterday urlli2 started throwing errors on most (but not all) attempts to access the remote URLs. The error is:
URLError: urlopen error [Errno -2] Name or service not known
What could cause 90% of remote requests to suddenly fail? What does [Errno -2]
actually mean??
I have searched the urllib2
docs but found no real explanation of [Errno -2]
, also have searched here for any answers without success.
Help please?
Additional info:
- I can also access the URL from my own browser, so it's not a bad URL.
- I can ping the remote domain from my server with no failures at all.
- As I mentioned, it does not fail 100% of the time, but about 95%.
The traceback stack looks like this:
File "/var/www/html/pylaw/http.py", line 8, in urlopen
X = urllib2.urlopen(url, data=d).read()
File "/usr/local/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/local/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
File "/usr/local/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
File "/usr/local/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.7/urllib2.py", line 1215, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/usr/local/lib/python2.7/urllib2.py", line 1177, in do_open
raise URLError(err)
URLError: urlopen error [Errno -2] Name or service not known