Max Open Connections settings

Hi @amir.jawaid and welcome to the Mattermost forums!

The SqlSettings.MaxOpenConns variable in your Mattermost server’s config.json file is telling the server how many connections it should be able to open to the database at maximum. The value you can see when running the query on your database server is the maximum possible connections your database server is configured to accept, so if the connections in the Mattermost server are higher than the ones from your database server, you might run into a situation where the Mattermost server tries to open a connection to the database and fails, because the MySQL server refuses the connection with an error message about having reached the maximum possible connections.
You should either lower the SqlSettings.MaxOpenConns setting in your Mattermost server to a value below the MySQL servers setting, or you should increase the possible connections on your MySQL server. For the latter, please be aware that allowing more connections will also increase memory usage and other system resources on your MySQL server, so I’d suggest to check how many connections have been made at maximum during the last server restart, which should give you an idea of what to set this value to.
You can use the following query to see the maximum used connection count since the last server startup (15 on my demo system):

mysql> show status like "Max_used_connections";
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 15    |
+----------------------+-------+
1 row in set (0.00 sec)