title: Django: [Errno 10054] An existing connection was forcibly closed by the remote host When using urllib2 and httplib2
body: <pre><code>def scrape(request):
      url = request.GET.get('url')
      conn = httplib2.Http()
      resp, content = conn.request(uri=url)
      return HttpResponseRedirect(content)
  
  def scrape1(request):
      url = request.GET.get('url')
      req = urllib2.Request(url, headers={ 'User-Agent': 'Magic Browser' })
      con = urllib2.urlopen(req)
  </code></pre>
  
  <p>When I use either of these functions using this url, <a href="http://gizmodo.com/5980796/first%20ever-incredible-footage-of-a-thought-being-formed" rel="nofollow">http://gizmodo.com/5980796/first%20ever-incredible-footage-of-a-thought-being-formed</a>, I get the following error message:</p>
  
  <p>[Errno 10054] An existing connection was forcibly closed by the remote host</p>
  
  <p>This happens when I run this function in a view within my Django app. However, if I run these series of commands in a python shell, I do not get an error and the url is retrieved successfully. Please help me understand what I am doing wrong and how I can fix it so I don't get this error anymore. Thank you.</p>