[Tox] npm gives URLError

asked 2017-07-23 20:07:07 -0600

anonymous user



I have started using DevStack recently and while running tox -e npm on /opt/stack/horizon, the following error is displayed:

Traceback (most recent call last):
  File "/opt/stack/horizon/.tox/npm/bin/nodeenv", line 11, in <module>
  File "/opt/stack/horizon/.tox/npm/local/lib/python2.7/site-packages/nodeenv.py", line 1019, in main
    opt.node = get_last_stable_node_version()
  File "/opt/stack/horizon/.tox/npm/local/lib/python2.7/site-packages/nodeenv.py", line 953, in get_last_stable_node_version
    response = urlopen('https://%s/dist/latest/' % (src_domain))
  File "/opt/stack/horizon/.tox/npm/local/lib/python2.7/site-packages/nodeenv.py", line 557, in urlopen
    return urllib2.urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open
  File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -5] No address associated with hostname>

The URL 'https://%s/dist/latest/' % (src_domain) points to https://nodejs.org/dist/latest/ and running curl https://nodejs.org/dist/latest/ does not result in the same issue.

I believe similar questions had been asked online but none of them seem to provide a good answer to this. Does anybody know a solution to this problem?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-07-24 20:47:20 -0600

yeexinc gravatar image

updated 2017-07-24 20:49:26 -0600

The problem was that I was working behind a proxy.

I added the following codes in the urlopen(url) function:

def urlopen(url):
      home_url = "https://github.com/ekalinin/nodeenv/"

      proxy = urllib2.ProxyHandler({'https' : 'http://example@proxywebsite:proxyport/'})
      opener = urllib2.build_opener(proxy)

      headers = {'User-Agent': 'nodeenv/%s (%s)' % (nodeenv_version, home_url     )}
      req = urllib2.Request(url, None, headers)
      return urllib2.urlopen(req)

Based on this answer: https://stackoverflow.com/questions/1450132/proxy-with-urllib2 (https://stackoverflow.com/questions/1...)

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2017-07-23 20:07:07 -0600

Seen: 124 times

Last updated: Jul 24 '17