Skip to main content

Matomo Analytics Archiving Fix

Matomo archiving may fail if plugins can’t read environment variables, causing database errors. The issue is usually fixed by adding a cron job to run Matomo’s archive task. If problems persist, conflicting plugins like may be the cause.

If Matomo-analytics archiving does not work on WordPress site it is most likely caused by plugins inability to read environmental variables which causes following error message:

Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at $DB_HOST:3306. This could mean your host's database server is down. Are you sure you have the correct username and password? Are you sure you have typed the correct hostname? Are you sure the database server is running?

Cron Job to Fix Archiving

Problem can be easily fixed by adding following cron job to crontab:

5 * * * * /usr/local/bin/wp cron event run matomo_scheduled_archive

Cron job can be added to crontab using SSH-connection with command crontab -e.

Possible Plugin Conflicts

If issue does not get fixed with cron job it is possible that site has active plugins that are not compatible with Matomo-analytics like WP Rocket and Google Listing and Ads.

More on Matomo combatible plugins can be found on their website.

Did this answer your question?