title: Scrapy + Tor + Mongodb
body: <p>I face a problem when using Scrapy + Mongodb with Tor. I get the following error when I try to have a mongodb pipeline in Scrapy.</p>
  
  <pre><code>2012-11-05 13:41:14-0500 [scrapy] DEBUG: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
  |S-chain|-&lt;&gt;-127.0.0.1:9050-&lt;&gt;&lt;&gt;-127.0.0.1:27017-&lt;--denied
  Traceback (most recent call last):
    File "/usr/bin/scrapy", line 4, in &lt;module&gt;
      execute()
    File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 131, in execute
      _run_print_help(parser, _run_command, cmd, args, opts)
    File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 97, in _run_print_help
      func(*a, **kw)
    File "/usr/lib/python2.7/dist-packages/scrapy/cmdline.py", line 138, in _run_command
      cmd.run(args, opts)
    File "/usr/lib/python2.7/dist-packages/scrapy/commands/crawl.py", line 42, in run
      q = self.crawler.queue
    File "/usr/lib/python2.7/dist-packages/scrapy/command.py", line 33, in crawler
      self._crawler.configure()
    File "/usr/lib/python2.7/dist-packages/scrapy/crawler.py", line 43, in configure
      self.engine = ExecutionEngine(self.settings, self._spider_closed)
    File "/usr/lib/python2.7/dist-packages/scrapy/core/engine.py", line 33, in __init__
      self.scraper = Scraper(self, self.settings)
    File "/usr/lib/python2.7/dist-packages/scrapy/core/scraper.py", line 66, in __init__
      self.itemproc = itemproc_cls.from_settings(settings)
    File "/usr/lib/python2.7/dist-packages/scrapy/middleware.py", line 33, in from_settings
      mw = mwcls()
    File "/home/bharani/ABCD_scraper/political_forum_scraper/pipelines.py", line 9, in __init__
      settings['MONGODB_PORT'])
    File "/usr/local/lib/python2.7/dist-packages/pymongo/connection.py", line 290, in __init__
      self.__find_node()
    File "/usr/local/lib/python2.7/dist-packages/pymongo/connection.py", line 586, in __find_node
      raise AutoReconnect(', '.join(errors))
  pymongo.errors.AutoReconnect: could not connect to localhost:27017: [Errno 111] Connection refused
  </code></pre>
  
  <p>I am not sure how to resolve this. When I do not use <code>proxychains</code>, it crawls perfectly fine.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>It's not code specific. See this link: <a href="http://isbullsh.it/2012/04/Web-crawling-with-scrapy/" rel="nofollow">http://isbullsh.it/2012/04/Web-crawling-with-scrapy/</a></p>
  
  <p>This is a simple tutorial to use <code>Scrapy</code> with <code>MongoDB</code>. We are supposed to call</p>
  
  <p><code>scrapy crawl isbullshit</code></p>
  
  <p>to run the crawler which works perfectly fine. To use <code>Tor</code>, it should be called like this:</p>
  
  <p><code>proxychains scrapy crawl isbullshit</code></p>
  
  <p>Which does not work for me. The source code of the tutorial is here: <a href="https://github.com/BaltoRouberol/isbullshit-crawler" rel="nofollow">https://github.com/BaltoRouberol/isbullshit-crawler</a></p>