Oops… there was a problem during the request. - Failed to write cache file

Apache 2.4 on Windows 10 PRO
Matomo version: 4.11.0
MySQL version: 10.6.5-MariaDB
PHP version: 8.1.10

Is this a bug in the templates_actionCommon.twig plugin?

ERROR Piwik\FrontController[2022-09-17 00:53:55 UTC] [d2725] Uncaught exception: C:\www\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=6187, CLI mode: 0]

ERROR Piwik\FrontController[2022-09-17 00:59:56 UTC] [ccc55] Uncaught exception: C:\www\matomo\plugins\CoreHome\templates_dataTableCell.twig(16): An exception has been thrown during the rendering of a template (“Failed to write cache file “C:\www\matomo/tmp/templates_c/3a/4af2187633f05753b74fcaa33ed3wbb5.php”.”). [Query: ?date=2022-08-17,2022-09-15&module=Referrers&action=getKeywords&widget=1&isFooterExpandedInDashboard=0&disableLink=0&filter_limit=50&idSite=1&period=range, CLI mode: 0]

Or am I missing something in the php.ini file?

UPDATE: I since added “Authenticated User” to the Security Group and the Failed to write cache file error is now no more. But on /index.php?module=CoreHome&action=index&date=previous30&period=range&idSite=2#?idSite=2&period=range&date=previous30&category=General_Visitors&subcategory=Live_VisitorLog I am still getting this error:

ERROR Piwik\FrontController[2022-09-17 14:53:29 UTC] [c2a69] Uncaught exception: C:\www\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=9281, CLI mode: 0]

Hi,
Do you have some “exotic” char in your tracking, like accents, Cyrillic chars, etc?
How is configured the database charset?

Database Collation is set to utf8mb4_general_ci

Yes - it is possible that I may have accents in setDocumentTitle. I use:

var _paq = _paq || ;
_paq.push([“setDocumentTitle”,“<%= TitleContentHolder %>”]);

where TitleContentHolder may include French or other “exotic” characters.

To note is that it is the page “Visitors > Visits Log” that produces

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.

And if I go to “Visitors > Locations” I get the error too, but after several page refresh I finally see the errors go away.

I am still – occasionally – getting

\CoreHome\templates_dataTableFooter.twig(21): An exception has been thrown during the rendering of a template ("Failed to write cache file

Looking at the Network tab I see that I get 500 Internal Server Errors on these pages with these errors.

@innocraft do you have some clues?

I just got this (hope it helps)

ERROR Piwik\ExceptionHandler[2022-09-20 16:18:09 UTC] [f5c24] Uncaught exception: C:\www\matomo\vendor\twig\twig\src\Cache\FilesystemCache.php(76): Failed to write cache file “C:\www\matomo/tmp/templates_c/8b/8b0854839659e496ee6fc33db6686b6e.php”. [Query: ?date=2022-08-21&module=Referrers&action=getKeywords&widget=1&isFooterExpandedInDashboard=0&disableLink=0&filter_limit=50&idSite=2&period=month, CLI mode: 0]

It looks like PHP is just not having the proper permissions to use C:\www\matomo/tmp to write files to.

Could it be that it has to do with my setup? I have 2 PHP running side by side. One for IIS (php-8.1.10-nts-Win32-vs16-x64) and one for Apache (php-8.1.10-Win32-vs16-x64). They are configured separately and kept apart.

And just got these:

Error in Matomo: The date 'today' is not a correct date range. It should have the following format: 'lastN', 'previousN', 'YYYY-MM-DD,YYYY-MM-DD'.

Error in Matomo: Failed to write cache file "C:\www\matomo/tmp/templates_c/8b/8a0854839659c496ee6fc33db6686b6e.php".

Error in Matomo: The file : can not be opened in write mode.

And I forgot to mention, the error only happens with site ID 2. No errors that I know of with the other sites. Site 1 has much more traffic; 2 has not much at all.

Hi @courtens Matomo may in rare cases display an error such as ‘Oops… there was a problem during the request.’ or ‘Internal Server Error’ or ‘500 error’.

When you have such problem, please follow the following steps to resolve the issue:

  1. The most common solution to the message Oops... there was a problem during the request. is to setup Auto-Archiving in your Matomo by following these two steps:
    a) Enabling the crontab to run the core:archive command and
    b) Disabling “Archive reports when viewed from the browser” in the General Settings.
  2. If the error persists, or you’re getting a white screen/page (sometimes called the ‘White screen of death’), it indicates that there is a problem on the server: check in your web server error log file for an error message.
1 Like

Thank you for that information V.K.

Please find above my errors I am getting. The error is “persisting” :roll_eyes:

I have the same error, but am using the wordpress plugin. Those instructions say If you are using Matomo for WordPress , you don’t need to do this as it utilises the WP Cron

I have posted twice asking for help on this and its for a client. I really need to get it sorted. I hate to hijack someone elses post, but I need answers as well

1 Like

I updated to 4.12.1 and the error persists. Finally the “Visit in real-time” is working for the troubled domain name, but “Visits Log” is still returning “Oops… there was a problem during the request.”

I followed your suggestion of disabling “Archive reports when viewed from the browser” in the General Settings, and have setup Windows: How to Set up Auto-Archiving Using Windows Scheduler.

Error log (Windows Logs Application) I get

Fault bucket 2030093307063167446, type 4
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: php-cgi.exe
P2: 8.1.10.0
P3: 630e526d
P4: php8.dll
P5: 8.1.10.0
P6: 630e5af2
P7: c0000005
P8: 0000000000005417
P9:
P10:

Attached files:
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER6EA9.tmp.dmp
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER6EF8.tmp.WERInternalMetadata.xml
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER6F09.tmp.xml
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER6F09.tmp.csv
\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER6F29.tmp.txt

These files may be available here:
\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_php-cgi.exe_e7c22930974321c49c5812606cc767d5a429c3f6_2b7980f3_489a0859-4aa0-4d17-80bd-3fd7bff87928

Analysis symbol:
Rechecking for solution: 0
Report Id: 4090d5d2-65a6-44dd-9453-7b35e41e9ad6
Report Status: 268435456
Hashed bucket: d7379339d968842c2c2c571b5c65e9d6
Cab Guid: 0

and find no files in the suggested locations on the server. The "C:\ProgramData\Microsoft\Windows\WER\Temp" is empty. I am not sure if the above php crash is actually related to the problem: “Oops… there was a problem during the request.”

matomo.log:

ERROR Piwik\FrontController[2022-10-19 05:35:38 UTC] [64575] Uncaught exception:C:\matomo\plugins\Live\templates\getLastVisitsStart.twig(76): The string to escape is not a valid UTF-8 string. [Query: ?date=2022-10-05,2022-10-17&module=Live&action=getLastVisitsStart&idSite=2&period=range, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:36:50 UTC] [a02ef] Uncaught exception: C:\matomo\plugins\CoreVisualizations\templates_dataTableViz_htmlTable.twig(11): An exception has been thrown during the rendering of a template (“Failed to write cache file “C:\matomo/tmp/templates_c/ce/cee8a44a4cabd76257f3dda3e3b87061.php”.”). [Query: ?date=2022-10-05,2022-10-17&module=DevicesDetection&format=html&action=getType&period=range&idSite=2&segment=&widget=&showtitle=1&random=9594, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:36:50 UTC] [8d7cc] Uncaught exception: C:\matomo\plugins\CoreVisualizations\templates_dataTableViz_htmlTable.twig(52): An exception has been thrown during the rendering of a template (“Failed to write cache file “C:\matomo/tmp/templates_c/ed/ed85ccdd78d58901b7a926c183fdbe13.php”.”). [Query: ?date=2022-10-05,2022-10-17&module=DevicesDetection&format=html&action=getModel&period=range&idSite=2&segment=&widget=&showtitle=1&random=6940, CLI mode: 0]

ERROR API[2022-10-19 15:38:58 UTC] [56dfd] Uncaught exception in API: You can’t access this resource as it requires ‘view’ access for the website id = 1. C:\matomo\core\Access.php:756

ERROR Piwik\ExceptionHandler[2022-10-19 15:38:59 UTC] [aef22] Uncaught exception: C:\matomo\core\API\Request.php(472): This user has super-user access. Embedding widgets with super-user token authentication is not allowed. Check the FAQ for more info. [Query: ?date=2022-10-06,2022-10-19&module=Annotations&action=getEvolutionIcons&idSite=1&period=range&filter_limit=-1, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:40:08 UTC] [648e1] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=374, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:40:22 UTC] [2d877] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=7549, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:40:33 UTC] [a82a9] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=2022-10-04,2022-10-18&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=9191, CLI mode: 0]

ERROR Piwik\ExceptionHandler[2022-10-19 15:50:24 UTC] [b221e] Uncaught exception: C:\matomo\vendor\twig\twig\src\Cache\FilesystemCache.php(76): Failed to write cache file “C:\matomo/tmp/templates_c/d4/d4edc4546262ebe318340d73fed70587.php”. [Query: ?date=2022-09-19,2022-10-18&module=Referrers&action=getKeywords&widget=1&isFooterExpandedInDashboard=0&disableLink=0&filter_limit=50&idSite=1&period=range, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:51:40 UTC] [3d66f] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=1139, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 15:52:20 UTC] [e84da] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=634, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 16:29:12 UTC] [ea66c] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=449, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 16:30:40 UTC] [1ccc1] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=4120, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 16:32:01 UTC] [b6ec4] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=6397, CLI mode: 0]

ERROR Piwik\FrontController[2022-10-19 16:37:31 UTC] [2da0f] Uncaught exception: C:\matomo\plugins\Live\templates_actionCommon.twig(25): The string to escape is not a valid UTF-8 string. [Query: ?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=6278, CLI mode: 0]

At a closer look it looks to me like it could be a Windows back-slash forward-slash problem in the way C:\matomo/tmp/templates_c/ce/cee8a44a4cabd76257f3dda3e3b87061.php it trying to write the temp file. But this would be odd - because it would not explain why just that on domain name has the problem, all the other domain names do not have that problem.

Do they use the same Matomo files (at the same location)?
Maybe one “server” blocks the other one…

@heurteph-ei
Do they use the same Matomo files (at the same location)?
Maybe one “server” blocks the other one…

The installs are separate. Apache calls use one, IIS uses the other PHP install. Matomo is configured to use direct request from Apache server.

What is strange is that it is just one account that has that problem. The others work well.

Then if I understand well, the 2 instances are installed on separated physical or virtual servers (not on the same one)?
It seems there is some right access problem in one of your configurations… Why not installing both with the same config (the one that works! :wink: )

The two instances are installed on the same physical server. I am running Apache directly and IIS calls via Apache proxy. But this should not matter … I think … because the error only appears on ONE of the websites. None of the others have that problem.

I just updates to the latest update
Matomo version: 4.12.3
MySQL version: 10.6.5-MariaDB
PHP version: 8.1.10

And I am still getting that error with that ONE PARTICULAR SITE on the page: Visitors > “Visits Log” (category=General_Visitors&subcategory=Live_VisitorLog). The similar page on (category=Dashboard_Dashboard) “Visits in real-time” works.
As explained above – none of the other sites have that error on “Visits Log”.

I get error:

Warning: the module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=7448 request failed!

Is it the same as:

:question:

Yes, it is the same page I am having in problem with.

Using that page is doing a xhr POST to (https://www.domainname.com/matomo/index.php?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&idSite=2&period=range&segment=&widget=&showtitle=1&random=1939) which produces a 500 Internal Server Error.

produces not error

Disable Cache
77 requests
4.69 MB / 1.85 MB transferred
Finish: 5.73 s
DOMContentLoaded: 2.59 s
load: 2.76 s
	
POST
	https://www.domainname.com/matomo/index.php?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=1&segment=&widget=&showtitle=1&random=7023
Status
200
OK
VersionHTTP/1.1
Transferred1.35 MB (1.35 MB size)
Referrer Policyno-referrer-when-downgrade

	
Cache-Control
	no-store, must-revalidate
Connection
	Keep-Alive
Content-Security-Policy
	default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' 'unsafe-inline' 'unsafe-eval' data:;, 1; mode=block;
Content-Type
	text/html; charset=utf-8
Date
	Thu, 03 Nov 2022 22:08:03 GMT
Keep-Alive
	timeout=5, max=99
Referrer-Policy
	no-referrer-when-downgrade
Server
	Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/8.1.10
Set-Cookie
	MATOMO_SESSID=xxxxxxxx; expires=Thu, 17-Nov-2022 22:08:03 GMT; path=/; secure; httponly; SameSite=Lax
Strict-Transport-Security
	max-age=31536000; includeSubdomains;
Transfer-Encoding
	chunked
X-Content-Type-Options
	nosniff
X-Frame-Options
	SAMEORIGIN
X-Matomo-Request-Id
	9c2de
X-Powered-By
	PHP/8.1.10
X-XSS-Protection
	1; mode=block;

    	
    POST /matomo/index.php?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=1&segment=&widget=&showtitle=1&random=7023 HTTP/1.1

    Host: www.domainname.com

    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0

    Accept: text/html, */*; q=0.01

    Accept-Language: en-US,en;q=0.5

    Accept-Encoding: gzip, deflate, br

    Referer: https://www.domainname.com/matomo/index.php?module=CoreHome&action=index&date=previous30&period=range&idSite=1

    X-Requested-With: XMLHttpRequest

    Origin: https://www.domainname.com

    Connection: keep-alive

    Cookie: ASPSESSIONIDCSQBABAS=KOELNBNACBIOGDNDFONABLON; ASPSESSIONIDQACQSCAQ=FMIJAMEDMKEAPKDGBIJFFFFJ; MATOMO_SESSID=xxxxxxxx; ASPSESSIONIDSABAASBB=GAHPJGIDIJHNAPCOCENKLHIB; ASPSESSIONIDSSBACQCC=HBFIJAEDIHCLJCFLFMHFIJDH; ASPSESSIONIDSQDCATCD=HOAJINMAEEDPBBLMELLEBHCB; ASPSESSIONIDSACBBTAA=AMKDGAOCPHFABMGHPLKDMOPE; pp=y

    Sec-Fetch-Dest: empty

    Sec-Fetch-Mode: cors

    Sec-Fetch-Site: same-origin

    Sec-GPC: 1

    Content-Length: 0

produces error:


Disable Cache
15 requests
524.77 KB / 510.44 KB transferred
Finish: 2.58 s
DOMContentLoaded: 687 ms
load: 907 ms
	
POST
	https://www.domainname.com/matomo/index.php?date=previous30&module=Live&format=html&forceView=1&viewDataTable=VisitorLog&action=getLastVisitsDetails&small=1&period=range&idSite=2&segment=&widget=&showtitle=1&random=848
Status
500
Internal Server Error
VersionHTTP/1.1
Transferred8.14 KB (7.37 KB size)
Referrer Policyno-referrer-when-downgrade

	
HTTP/1.1 500 Internal Server Error

Date: Thu, 03 Nov 2022 22:10:01 GMT

Server: Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/8.1.10

Strict-Transport-Security: max-age=31536000; includeSubdomains;

X-Frame-Options: SAMEORIGIN

X-Powered-By: PHP/8.1.10

X-Matomo-Request-Id: f075a

Cache-Control: no-store, must-revalidate

Set-Cookie: MATOMO_SESSID=xxxxxxxx; expires=Thu, 17-Nov-2022 22:10:01 GMT; path=/; secure; httponly; SameSite=Lax

Referrer-Policy: no-referrer-when-downgrade

Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' 'unsafe-inline' 'unsafe-eval' data:;, 1; mode=block;

X-XSS-Protection: 1; mode=block;

X-Content-Type-Options: nosniff

Content-Length: 7545

Connection: close

Content-Type: text/html; charset=utf-8
	
Accept
	text/html, */*; q=0.01
Accept-Encoding
	gzip, deflate, br
Accept-Language
	en-US,en;q=0.5
Connection
	keep-alive
Content-Length
	0
Cookie
	ASPSESSIONIDCSQBABAS=KOELNBNACBIOGDNDFONABLON; ASPSESSIONIDQACQSCAQ=FMIJAMEDMKEAPKDGBIJFFFFJ; MATOMO_SESSID=xxxxxxxx; ASPSESSIONIDSABAASBB=GAHPJGIDIJHNAPCOCENKLHIB; ASPSESSIONIDSSBACQCC=HBFIJAEDIHCLJCFLFMHFIJDH; ASPSESSIONIDSQDCATCD=HOAJINMAEEDPBBLMELLEBHCB; ASPSESSIONIDSACBBTAA=AMKDGAOCPHFABMGHPLKDMOPE; pp=y
Host
	www.domainname.com
Origin
	https://www.domainname.com
Referer
	https://www.domainname.com/matomo/index.php?module=CoreHome&action=index&date=previous30&period=range&idSite=2
Sec-Fetch-Dest
	empty
Sec-Fetch-Mode
	cors
Sec-Fetch-Site
	same-origin
Sec-GPC
	1
User-Agent
	Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0

    X-Requested-With
    	XMLHttpRequest


I have no more idea, then I think you can create an issue at:
https://github.com/matomo-org/matomo/issues/new?assignees=&labels=Potential+Bug&template=bug_report.md