Skip to main content

Why is Sentry not capturing HTTP exceptions in my Laravel app?

Issue

The Sentry SDK is not capturing HTTP exceptions (such as 404 and 403 responses) raised in my Laravel app, and I want to know why and how to capture them.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • Laravel SDK

  • Laravel 11 and later

Resolution

Laravel ignores certain HTTP exceptions by default, including 404 (not found), 403 (origin mismatch), and 419 (invalid CSRF token). Because Laravel never reports them, they do not reach the Sentry integration, so Sentry cannot capture them.

To capture them, tell Laravel to stop ignoring the exception type in your bootstrap/app.php, alongside the Sentry integration registration:

// bootstrap/app.php
use Symfony\Component\HttpKernel\Exception\HttpException;
use Sentry\Laravel\Integration;

->withExceptions(function (Exceptions $exceptions) {
$exceptions->stopIgnoring(HttpException::class);
Integration::handles($exceptions);
})->create();

Laravel provides the stopIgnoring method for this. For details on which exceptions Laravel ignores and how stopIgnoring works, see Laravel's error handling documentation (maintained by Laravel, not Sentry). For the base Sentry setup in bootstrap/app.php, see the Sentry Laravel guide.

Note: un-ignoring HttpException captures all matching HTTP exceptions, including every 404, which can be high-volume. If you only want specific cases, capture them selectively rather than un-ignoring the whole class.

Did this answer your question?