SOLVED Could not connect to the database. Please refer to sugarcrm.log for details

Today our web site comes up with the above error message. There are no errors in the PHP.log and the only messages in the suitecrm.log are:

hu Aug 12 16:18:12 2021 [84780][4ff6b317-f8de-29a4-bac5-5805de74ab81][FATAL] SugarPHPMailer encountered an error: Invalid address:
Fri Aug 13 08:23:15 2021 [86499][4ff6b317-f8de-29a4-bac5-5805de74ab81][ERROR] Unable to load related bean by id
Fri Aug 13 08:27:25 2021 [86499][4ff6b317-f8de-29a4-bac5-5805de74ab81][ERROR] Unable to load related bean by id
Fri Aug 13 08:29:46 2021 [86500][4ff6b317-f8de-29a4-bac5-5805de74ab81][ERROR] Unable to load related bean by id
Fri Aug 13 08:30:02 2021 [86502][4ff6b317-f8de-29a4-bac5-5805de74ab81][ERROR] Unable to load related bean by id
Fri Aug 13 08:30:20 2021 [86517][4ff6b317-f8de-29a4-bac5-5805de74ab81][ERROR] Unable to load related bean by id
Fri Aug 13 10:26:25 2021 [1411][4ff6b317-f8de-29a4-bac5-5805de74ab81][ERROR] Field dateclosed_c expecting datetime format, but got value:
Fri Aug 13 10:26:26 2021 [1411][4ff6b317-f8de-29a4-bac5-5805de74ab81][FATAL] SugarPHPMailer encountered an error: Invalid address:

I have checked the config file for the database details and these are correct.

I have logged on to the database and done show tables which brings up a list of tables so database is working correctly.

I have even tried restarting the server and then checked mysql and httpd services are running.

I have checked the server for diskspace and only 19% of the available space is in use. I don’t know what else to try,

I’ve done some more testing. I created a file that attaches to the database and lists all the name in a table and that produces an output so the database is definitely available.

echo “Testing database connection”;

$link = mysqli_connect(“localhost”, “user”, “password”, “database_name”);

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}

echo "
Connected Successfully. Host info: " . mysqli_get_host_info($link);

// Attempt select query execution
$sql = “SELECT * FROM hscrm.accounts
where deleted = 1
order by name”;
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo “

”;
echo “”;

    echo "<th>name</th>";

    echo "</tr>";
    while($row = mysqli_fetch_array($result)){
        echo "<tr>";
        echo "<td>" . $row['name'] . "</td>";

        echo "</tr>";
    }
    echo "</table>";
    // Free result set
    mysqli_free_result($result);
} else{
    echo "<br>No records matching your query were found.";
}

} else{
echo "
ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);

I’ve got this working again. When I checked the config file I must have been looking at my local copy not the copy on the server as it turns out the values were different in there. This is a bit strange as I have no idea how these values could have changed. Anyway, its working now