infiniflow/ragflow · error · Exception

Database Connection Failed! \n

Error message

Database Connection Failed! \n{e}

What it means

Error "Database Connection Failed! \n{e}" thrown in infiniflow/ragflow.

Solutions

  1. Verify host, port, credentials, and database name for the connection.
  2. Check network reachability and that the database server is running, then retry.

Example fix

# test connectivity first
import pymysql
conn = pymysql.connect(host=host, port=port, user=user, password=pwd, database=db)

When it happens

Trigger: Thrown at agent/tools/exesql.py:178 when the library encounters an invalid state.

Common situations: The database server is unreachable, credentials are wrong, or the target database does not exist; validating the connection settings prevents this error.


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/fe86499496489eba. Report an issue: GitHub.

Appendix: source

Thrown at agent/tools/exesql.py:178

                else:
                    c, s = db, "default"
                return c, s

            catalog, schema = _parse_catalog_schema(self._param.database)
            if not catalog:
                raise Exception("For Trino, `database` must be 'catalog.schema' or at least 'catalog'.")

            http_scheme = "https" if os.environ.get("TRINO_USE_TLS", "0") == "1" else "http"
            auth = None
            if http_scheme == "https" and self._param.password:
                auth = BasicAuthentication(self._param.username, self._param.password)

            try:
                db = trino.dbapi.connect(
                    host=safe_host, port=int(self._param.port or 8080), user=self._param.username or "ragflow", catalog=catalog, schema=schema or "default", http_scheme=http_scheme, auth=auth
                )
            except Exception as e:
                raise Exception("Database Connection Failed! \n" + str(e))
        elif self._param.db_type == "IBM DB2":
            import ibm_db

            conn_str = f"DATABASE={self._param.database};HOSTNAME={safe_host};PORT={self._param.port};PROTOCOL=TCPIP;UID={self._param.username};PWD={self._param.password};"
            try:
                conn = ibm_db.connect(conn_str, "", "")
            except Exception as e:
                raise Exception("Database Connection Failed! \n" + str(e))

            try:
                sql_res = []
                formalized_content = []
                for single_sql in sqls:
                    if self.check_if_canceled("ExeSQL processing"):
                        return

                    single_sql = single_sql.replace("```", "").strip()
                    if not single_sql:

View on GitHub (pinned to 554fb1133a)