---
title: "Health check — Plausible for Laravel | Roundly"
description: "Check configuration and API connectivity without throwing — ping(), health() and the plausible:health Artisan command."
url: https://roundly-consulting.com/open-source/docs/plausible-for-laravel/health-check
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Plausible for Laravel](https://roundly-consulting.com/open-source/docs/plausible-for-laravel.md)

# Health check

Verify configuration and connectivity without throwing:

```php
Plausible::ping();                  // bool — reachable AND the key is accepted
Plausible::ping('my-site.com');     // same, verified against this site

$health = Plausible::health();      // HealthResult — never throws
$health = Plausible::health('my-site.com');

$health->ok();                      // configured, reachable and the key accepted
$health->isConfigured();            // url and key are both set
$health->hasUrl;                    // bool
$health->hasKey;                    // bool
$health->reachable;                 // the instance answered (no connection error, 5xx or 404)
$health->authorized;                // the probe was answered 2xx with the key
$health->status;                    // ?int — HTTP status of the probe, null when not reached
$health->message;                   // human-readable status
```

health() first checks that url and key are set. The probe then depends on what it can verify:

- With a site — the argument, else PLAUSIBLE\_SITE — it calls the Stats API (GET /api/v1/stats/realtime/visitors), which a Stats API key can reach.
- Without one it calls the Sites API (GET /api/v1/sites), which only a Sites API key can reach; a refused Stats key is reported as such, with the fix — set PLAUSIBLE\_SITE or pass a site.

Only a 2xx passes. A server error (5xx) or a 404 — a wrong PLAUSIBLE\_URL — marks the instance unreachable; a 401, 402 or 403 means the key was refused, and a 429 means the key is rate-limited and could not be verified. A connection failure is reported in the message, never thrown. ping() is shorthand for health()->ok().

## Artisan command

A matching command reports the same — pass --site= to verify the key against that site’s Stats API:

```bash
php artisan plausible:health
php artisan plausible:health --site=my-site.com
```

```
Plausible health check
  URL configured: yes
  Key configured: yes
  Reachable:      yes
  Key accepted:   yes
  HTTP status:    200
Plausible is reachable and the API key can read stats for my-site.com.
```

It exits non-zero unless ok() — configured, reachable and the key accepted — so drop it into a deploy pipeline as a post-deploy check. php artisan about also shows a Plausible section (see Configuration).

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/plausible-for-laravel.md)
