400 Bad Request out of the blue (IIS)

Hi all,

We’ve been running Matomo in two environments for approximately a year in 1 production and 1 non-production environment. Out of the blue on Monday evening in our non-production environment the post-back to Matomo from browsers stopped accepting traffic and is reporting 400 Bad Request. Clients can call and load the matomo.js file perfectly fine, it’s the subsequent call that fails 100% of the time now. We’ve completely rebuilt the server (but reuse a backup of the Matomo IIS folder), isolated networks, removed firewalls, you name it we’ve tried it. This fails through our standard load balancer, HTTP and HTTPS, localhost, etc.

The Matomo UI works flawlessly, the only thing broken is the client data. We’re on 4.4.1, I also tried updating to 4.5.0 and it didn’t change a thing. Any help is greatly appreciated.

What can you see in the response body of HTTP 400 response?
Also have a look at:
https://matomo.org/faq/troubleshooting/faq_115/

In my working production instance, the response body is empty but with a 204 No Response.

In my non working non-production instance, the response is a 400 Bad Request with the body:

This resource is part of Matomo. Keep full control of your data with the leading free and open source web analytics & conversion optimisation platform.

This file is the endpoint for the Matomo tracking API. If you want to access the Matomo UI or use the Reporting API, please use index.php instead.

I enabled logging and captured this for the failing call: My URL has been masked with XXXXXXXXXX

DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] Debug enabled - Input parameters: array (
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘action_name’ => ‘’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘idsite’ => ‘23’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘rec’ => ‘1’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘r’ => ‘510498’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘h’ => ‘2’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘m’ => ‘3’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘s’ => ‘51’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘url’ => ‘http://XXXXXXXXXXXX/verify.html’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘_id’ => ‘baeb2c620b1b90ce’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘_idn’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘_refts’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘cs’ => ‘windows-1252’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘send_image’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘pdf’ => ‘1’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘qt’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘realp’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘wma’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘fla’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘java’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘ag’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘cookie’ => ‘1’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘res’ => ‘2560x1334’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘pv_id’ => ‘0xUIYJ’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘pf_net’ => ‘0’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘pf_srv’ => ‘4’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘pf_tfr’ => ‘1’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] ‘pf_dm1’ => ‘27’,
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] )
DEBUG Piwik\Tracker[2021-11-18 09:03:51 UTC] [0eec5] Tracker encountered an exception: {ex}
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] Exception: C:\inetpub\Matomo\core\Tracker\Db\Pdo\Mysql.php(238): Error query: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘matomo_uat_1.matomo_disable_site_tracking’ doesn’t exist In query:
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] SELECT
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] count(*) AS disabled
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] FROM matomo_disable_site_tracking
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] WHERE
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] siteId = ? AND
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] deleted_at IS NULL;
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] Parameters: array (
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] 0 => 23,
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] )
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #0 C:\inetpub\Matomo\core\Tracker\Db\Pdo\Mysql.php(153): Piwik\Tracker\Db\Pdo\Mysql->query()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #1 C:\inetpub\Matomo\core\Db.php(301): Piwik\Tracker\Db\Pdo\Mysql->fetchAll()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #2 C:\inetpub\Matomo\plugins\DisableTracking\DisableTracking.php(183): Piwik\Db::fetchAll()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #3 C:\inetpub\Matomo\plugins\DisableTracking\DisableTracking.php(158): Piwik\Plugins\DisableTracking\DisableTracking::isSiteTrackingDisabled()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #4 [internal function]: Piwik\Plugins\DisableTracking\DisableTracking->newTrackingRequest()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #5 C:\inetpub\Matomo\core\EventDispatcher.php(141): call_user_func_array()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #6 C:\inetpub\Matomo\core\Piwik.php(809): Piwik\EventDispatcher->postEvent()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #7 C:\inetpub\Matomo\core\Tracker\RequestSet.php(104): Piwik\Piwik::postEvent()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #8 C:\inetpub\Matomo\core\Tracker.php(136): Piwik\Tracker\RequestSet->initRequestsAndTokenAuth()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #9 C:\inetpub\Matomo\core\Tracker.php(115): Piwik\Tracker->track()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #10 C:\inetpub\Matomo\piwik.php(73): Piwik\Tracker->main()
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #11 C:\inetpub\Matomo\matomo.php(13): include(‘C:\inetpub\Mato…’)
ERROR Piwik\Tracker\Handler[2021-11-18 09:03:51 UTC] [0eec5] #12 {main} [Query: ?action_name=&idsite=23&rec=1&r=510498&h=2&m=3&s=51&url=http%3A%2F%2Fumatomows1.wcbdmz.ab.ca%2Fverify.html&_id=baeb2c620b1b90ce&_idn=0&_refts=0&cs=windows-1252&send_image=0&pdf=1&qt=0&realp=0&wma=0&fla=0&java=0&ag=0&cookie=1&res=2560x1334&pv_id=0xUIYJ&pf_net=0&pf_srv=4&pf_tfr=1&pf_dm1=27, CLI mode: 0]
DEBUG Piwik\Common[2021-11-18 09:03:51 UTC] [0eec5] Empty request => Matomo page
DEBUG Piwik\Common[2021-11-18 09:03:51 UTC] [0eec5] End of the page.
DEBUG Piwik\Common[2021-11-18 09:03:51 UTC] [0eec5] array (
DEBUG Piwik\Common[2021-11-18 09:03:51 UTC] [0eec5] )
DEBUG Piwik\Common[2021-11-18 09:03:51 UTC] [0eec5]

It looks like a table is missing…

Looking at Database schema: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v4, this table is unknown… Isn’t it from a newly installed plugin?

1 Like

Just before you replied I noticed that as well. It exists in our production instance, so I created it in the non-production instance and service has been restored.

CREATE TABLE `matomo_disable_site_tracking` (
  `id` int NOT NULL AUTO_INCREMENT,
  `siteId` int NOT NULL,
  `created_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

Thanks you so much for pointing me at that logging article, you’re a saint!