Please post more details on your case (share the entire debug log), so that it will be easier to understand the root cause.
Otherwise, I advise you to check the Debug configuration in the CubeIDE and make sure to select the adequate external loader. Check also your board stack size.