Issue: Database Connection Timeout During Mattermost Upgrade

Mattermost Version: Upgrading from 9.8.1 to 9.8.2 (also tried upgrading to 9.9.0) for Team Edition in Test Environment.
Error Message:

"timestamp": "2024-07-05 07:42:11.038 Z",
    "level": "error",
    "msg": "Failed to ping DB",
    "caller": "sql/sql_utils.go:75",
    "database": "master",
    "dataSource": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx?connect_timeout=10&sslmode=disable",
    "retrying in seconds": 10,
    "error": "dial tcp: lookup xxxxxxxxxxxxxxxxxxxx: i/o timeout"

During the upgrade the instance is unable to contact the Database, resulting in a timeout error.
Request:
Need help in resolving the issue during Mattermost Upgrade.