This error can happen if a long running query exceeds the connect_timeout value of the PostgreSQL connection string.
By default the `connect_timeout` value is set to 10 seconds. This is sufficient for most cases but for longer running queries like compliance exports or data retention this can cause issues.
To resolve this you need to increase the value in your SqlSettings.Datasource connection string which can be found either in your config.json or is passed as an environment variable during server start.
We suggest starting with a very high value like 120 or 240s and then looking at the export/deletion times to see how long the query takes so you can adjust it down to be closer to the actual time the query takes to complete.
Note: you need to restart the Mattermost server for this setting to take effect.
Article is closed for comments.