diff --git a/mongodb_cache/mongodb_cache_plugin.php b/mongodb_cache/mongodb_cache_plugin.php
index a9dc04d..21d8862 100644
--- a/mongodb_cache/mongodb_cache_plugin.php
+++ b/mongodb_cache/mongodb_cache_plugin.php
@@ -157,7 +157,14 @@ class Cache implements \DrupalCacheInterface {
     // Garbage collection necessary when enforcing a minimum cache lifetime.
     $this->garbageCollection();
 
-    $cache = $this->collection->findOne(['_id' => (string) $cid]);
+    try {
+      $cache = $this->collection->findOne(['_id' => (string) $cid]);
+    }
+    catch (MongoConnectionException $e) {
+      header('HTTP/1.0 502 Bad Gateway', TRUE, 503);
+      exit;
+    }
+
     $result = $this->prepareItem($cache);
     return $result;
   }
