504 Gateway Timeout


We are currently in the process of upgrading Matomo to the latest version 3.13.5 (currently running 3.13.1)
after the deployment of the new version with nginx and php-fpm, the agents on the monitored sites show a “504 Gateway Timeout” error on the browser.

after inspection I found this error in the nginx error log:
2020/05/25 06:34:59 [error] 13715#0: *480 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xx.xx.xx.xx, server: localhost, request: "GET /piwik.php?action_name=&idsite=xxxx&rec=1&r=379151&h=8&m=33&s=59&url=https%3A%2F%2Fxxx.xxxx.com&urlref=https%3A%2F%2Fxxx.xxxx.com&_id=xxxxx&_idts=1583823949&_idvc=80&_idn=0&_refts=0&_viewts=1590383892&send_image=1&pdf=0&qt=0&realp=0&wma=0&dir=0&fla=1&java=1&gears=0&ag=0&cookie=1&res=1536x864&gt_ms=184&pv_id=r361RB HTTP/1.1", upstream: "fastcgi://", host: "piwik.xxxx.com", referrer: "https://xxx.xxxx.com/pdi/path/to/page"

This happened for all the monitored sites.
I tried running fastcgi using a socket instead of a fixed port but the same thing happened.

I also made sure that matomo.php is being executed.

I am using PHP 7.2.24 and nginx/1.16.1

Is this a bug in the new version? can anyone help?


There is no known bug like this in the latest version and many people are already using it for a while.

Maybe updating takes longer than the max_execution_time allowed on your server and Matomo gets killed in the middle.
You could try updating manually instead:

Hi Lukas,

Thank you for your fast reply.

This is the link that I used for the upgrade.
I already tried increasing the max_execution_time but I still got the same error.
I Also tried removing and reinstalling Matomo


Have you also tried running the update on the commandline:

./path/to/matomo/console core:update

Yes, directly after the upgrade and before I allowed the monitored websites to call the matomo server (agents were stopped using DNS)

Is there a way to see (enable) the php logs from piwik.php?
Can i redirect them somewhere to see them as the error is happening?

As for the max_execution_time, I set it to 300 (instead of the original 30). There is no traffic on the server so I don’t see why the execution should take that long.

Is there anything else I could do that might help?