Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The problem is that with normal user I cannot open url's with python urllib2 library:

import urllib2
URLError: <urlopen error [Errno -2] Name or service not known>

I did a full traceback with ipython:

In [2]: urllib2.urlopen('http://www.google.com/')
URLError                                  Traceback (most recent call last)
<ipython-input-2-db1214eac385> in <module>()
----> 1 urllib2.urlopen('http://www.google.com/')

/usr/lib/python2.7/urllib2.pyc in urlopen(url, data, timeout)
    125     if _opener is None:
    126         _opener = build_opener()
--> 127     return _opener.open(url, data, timeout)
    129 def install_opener(opener):

/usr/lib/python2.7/urllib2.pyc in open(self, fullurl, data, timeout)
    402             req = meth(req)
--> 404         response = self._open(req, data)
    406         # post-process response

/usr/lib/python2.7/urllib2.pyc in _open(self, req, data)
    420         protocol = req.get_type()
    421         result = self._call_chain(self.handle_open, protocol, protocol +
--> 422                                   '_open', req)
    423         if result:
    424             return result

/usr/lib/python2.7/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
    380             func = getattr(handler, meth_name)
--> 382             result = func(*args)
    383             if result is not None:
    384                 return result

/usr/lib/python2.7/urllib2.pyc in http_open(self, req)
   1213     def http_open(self, req):
-> 1214         return self.do_open(httplib.HTTPConnection, req)
   1216     http_request = AbstractHTTPHandler.do_request_

/usr/lib/python2.7/urllib2.pyc in do_open(self, http_class, req)
   1182         except socket.error, err: # XXX what error?
   1183             h.close()
-> 1184             raise URLError(err)
   1185         else:
   1186             try:

URLError: <urlopen error [Errno -2] Name or service not known>

If I try the same thing after "sudo su -" everything is working fine, so my guess that it's something related to permissions.

Ubuntu and python version are:

Distributor ID: Ubuntu
Description:    Ubuntu 13.10
Release:    13.10
Codename:   saucy

python                                    2.7.5-5ubuntu1

Thank you

share|improve this question
I cannot reproduce this behaviour here (Python 2.7.5+, Ubuntu 13.10, 3.11.0-15, x86_64). Even as a normal user, everything is fine. –  Klaus Warzecha Jan 23 at 0:49
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.