diff --git a/nomad/datamodel/datamodel.py b/nomad/datamodel/datamodel.py
index 2fa0098b4bf0c472d19cd80f2e938cca2dd8dc2c..c7bb188ffe223189847b1204c3b0fcccbb74394c 100644
--- a/nomad/datamodel/datamodel.py
+++ b/nomad/datamodel/datamodel.py
@@ -78,7 +78,7 @@ logger = utils.get_logger(__name__)
 def _check_mongo_connection():
     try:
         from nomad.infrastructure import mongo_client
-    except ImportError | ModuleNotFoundError:
+    except Exception:
         return
 
     global has_mongo