diff --git a/CveXplore/main.py b/CveXplore/main.py
index 1f907bef6..d760babdb 100644
--- a/CveXplore/main.py
+++ b/CveXplore/main.py
@@ -144,7 +144,12 @@ def __init__(self, **kwargs):
         else:
             if self.datasource_type == "mongodb":
                 self._datasource_connection_details = {
-                    "host": f"{self.config.DATASOURCE_PROTOCOL}://{self.config.DATASOURCE_HOST}:{self.config.DATASOURCE_PORT}"
+                    "host": (
+                        f"{self.config.DATASOURCE_PROTOCOL}://{self.config.DATASOURCE_HOST}:{self.config.DATASOURCE_PORT}"
+                        if self.config.DATASOURCE_USER is None
+                        and self.config.DATASOURCE_PASSWORD is None
+                        else f"{self.config.DATASOURCE_PROTOCOL}://{self.config.DATASOURCE_USER}:{self.config.DATASOURCE_PASSWORD}@{self.config.DATASOURCE_HOST}:{self.config.DATASOURCE_PORT}"
+                    )
                 }
             elif self.datasource_type == "mysql":
                 self._datasource_connection_details = {