After update from 4.6.1 to 4.10.1 several widgets show "there was a problem during the request"

Hi,

I have updated our staging instance from 4.6.1 to 4.10.1. When I select a month that I know has data,
several widgets like “keyword”, “websites”, and “browsers” show an error message:

Oops… there was a problem during the request. Maybe the server had a temporary issue, or maybe you requested a report with too much data. Please try again. If this error occurs repeatedly please contact your Matomo administrator for assistance

I am the admin but this message doesn’t help. Also, I couldn’t find anything else in the logs from Apache oder PHP.

./console diagnostics:run has no relevant output.
Debian Bullseye, PHP 7.4

Where should I look next?

Is there any message in the browser console or in the HTTP response?

Yes, didn’t know you have to look there…

F12 > Console > expand “Uncaught (in promise)” > responseText > right click > Copy string contents

That gave me some HTML that I opened in the browser to get the underlying error:

An exception has been thrown during the rendering of a template (“Unable to write in the cache directory (/var/www/matomo.example.com/tmp/templates_c/94).”).
in /var/www/matomo.example.com/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig line 52

The directory was owned by root, so I changed this to the apache user:

chown -R www-data.www-data /var/www/matomo.example.com

Thanks for your help!