502 Bad Gateway after login

Hi Team,

Getting 502 Bad Gateway error after login. On reloading page multiple times, page sometimes load partially and give below error message:

WARNING: /var/www/html/piwik/libs/Zend/Db/Statement/Pdo.php(228): Warning - Error while sending QUERY packet. PID=17524 - Matomo 3.3.0 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)

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.

Any help will be highly appreciated.

Thanks!

Hi,

The error seems to come from PDO, which doesn’t seem to be able to connect to your MySQL-server.

Maybe check this out:

https://matomo.org/faq/troubleshooting/faq_183/

I have already checked these configs max_allowed_packet = 2048M & wait_timeout = 86400.
I tried restarting Mysql and it just loaded page partially with header links and on reloading it again displayed same error 502 Bad Gateway.

I have set-up cron job for archival process and cron script looks like this:
5 * * * * www-data /usr/bin/php /var/www/html/piwik/console core:archive --url=http://domain.com/piwik/ > /home/dsuser/archive/piwik-archive.log
And I can see the archival log getting updated every hour.

The reason why I set cron job was because I was getting 502 Bad gateway errors sometime.
Now when I change date range in Visitors->Overview page, for some date range it works fine whereas it gives error again if I select more than 2-3 months in range.
ERROR:
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.
Is there anything else I can do to improve performance.

Also only after running “/etc/init.d/php7.1-fpm restart” the 502 Bad Gateway error is gone and Matomo is up and running again. Any suggestions on what can be the issue as fpm log file is empty.