title: ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
body: <p><strong>strong text</strong>
  i was coding an python spider,and i use mongo database to storage the webpage's html and the crawl_queue_list.<strong>At first</strong> ,it runs well,i could create connection to the mongodb('localhost',20717) and get or set items to it .<strong>However, after about 3 hours</strong>,it raise an Exception. How should i deal with it?!!</p>
  
  <p><strong>the difference between my question and some exist question</strong> is that at the begining of my program,it's ok!everything runs well.I just go to  a sleep and after few hours,my mongodb refused any connection.The terminal that i type 'mongod -dbpath .' show that '已杀死'(chinese,means that it had beng killed).i don't know what happened to mongodb.Alos my computer's storage is enough</p>
  
  <pre><code>Exception in thread Thread-72:
  Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
  self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
  self.__target(*self.__args, **self.__kwargs)
  File "/home/lowen/PycharmProjects/nookDemo/process_crawler.py", line 44, in process_queue
  html = D(url)
  File "/home/lowen/PycharmProjects/nookDemo/downloader.py", line 49, in __call__
  self.cache[url] = result
  File "/home/lowen/PycharmProjects/nookDemo/mongo_cache.py", line 76, in __setitem__
  self.db.webpage.update({'_id': url}, {'$set': record}, upsert=True)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 2242, in update
  with self._socket_for_writes() as sock_info:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
  return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 762, in _get_socket
  server = self._get_topology().select_server(selector)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/topology.py", line 210, in select_server
  address))
  File "/usr/local/lib/python2.7/dist-packages/pymongo/topology.py", line 186, in select_servers
  self._error_message(selector))
  </code></pre>
  
  <p>ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused</p>