laravel/framework · error · RuntimeException

Failed to create broadcaster for connection

Error message

Failed to create broadcaster for connection "{$name}" with error: {$e->getMessage()}.

What it means

Thrown by BroadcastManager::resolve() when the resolved create{Driver}Driver method (or custom creator) throws any Throwable during broadcaster construction. The original error is wrapped in a RuntimeException preserving the connection name and the underlying message, with the original exception chained as previous. It signals a runtime failure of driver setup, not a misconfiguration of the connection key.

Solutions

  1. Inspect getPrevious() to read the underlying SDK/connection error and address it directly.
  2. Set the correct credentials in .env (PUSHER_APP_ID/KEY/SECRET/CLUSTER or REVERB_* or ABLY_KEY).
  3. Install the required SDK: composer require pusher/pusher-php-server (or ably/ably-php).
  4. Verify network egress to the broadcaster host/port from your environment.
  5. For local dev, switch the connection to 'log' or 'null' to isolate the issue.

Example fix

// before — Pusher credentials missing
// .env: PUSHER_APP_ID= / PUSHER_APP_KEY= / PUSHER_APP_SECRET=
// error: Failed to create broadcaster for connection "pusher" with error: app_key is required.

// after
// .env
PUSHER_APP_ID=1234567
PUSHER_APP_KEY=yourkey
PUSHER_APP_SECRET=yoursecret
PUSHER_APP_CLUSTER=mt1
// composer require pusher/pusher-php-server
// php artisan config:clear
Defensive patterns

Strategy: try-catch

Validate before calling

// PHP — pre-flight credentials for the Pusher connection
$name = config('broadcasting.default');
if (config("broadcasting.connections.{$name}.driver") === 'pusher') {
    foreach (['app_id','key','secret'] as $k) {
        if (empty(config("broadcasting.connections.{$name}.{$k}"))) {
            throw new \RuntimeException("Pusher {$k} is not set for connection [{$name}].");
        }
    }
    if (! class_exists(\Pusher\Pusher::class)) {
        throw new \RuntimeException('pusher/pusher-php-server is not installed.');
    }
}
Broadcast::driver($name);

Type guard

// Structural guard for runtime readiness (driver + SDK present)
function broadcasterSdkIsInstalled(string $driver): bool {
    return match ($driver) {
        'pusher' => class_exists(\Pusher\Pusher::class),
        'ably'   => class_exists(\Ably\AblyRest::class),
        default  => true,
    };
}

Try / catch

try {
    Broadcast::driver($name);
} catch (\RuntimeException $e) {
    $prev = $e->getPrevious();
    Log::error('Broadcaster creation failed', ['connection' => $name, 'cause' => optional($prev)->getMessage() ?? $e->getMessage()]);
    // fall back to a log/null connection to keep the app alive
    config(['broadcasting.default' => 'log']);
}

Prevention

When it happens

Trigger: createPusherDriver/createAblyDriver/etc. failing — e.g. missing Pusher/Ably SDK, invalid API keys/cluster, missing Guzzle HTTP client, network/DNS failure to the broadcaster endpoint, or a custom broadcaster constructor raising an exception.

Common situations: Pusher/Ably credentials unset or wrong (app_key/secret/cluster); Pusher SDK not installed; app_id empty; cluster mismatch (eu vs mt1); network egress blocked in CI/container; misconfigured Redis host for the redis broadcaster.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/ae5f96f3b09630dc. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Broadcasting/BroadcastManager.php:319

        if (is_null($config)) {
            throw new InvalidArgumentException("Broadcast connection [{$name}] is not defined.");
        }

        if (isset($this->customCreators[$config['driver']])) {
            return $this->callCustomCreator($config);
        }

        $driverMethod = 'create'.ucfirst($config['driver']).'Driver';

        if (! method_exists($this, $driverMethod)) {
            throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported.");
        }

        try {
            return $this->{$driverMethod}($config);
        } catch (Throwable $e) {
            throw new RuntimeException("Failed to create broadcaster for connection \"{$name}\" with error: {$e->getMessage()}.", 0, $e);
        }
    }

    /**
     * Call a custom driver creator.
     *
     * @param  array  $config
     * @return mixed
     */
    protected function callCustomCreator(array $config)
    {
        return $this->customCreators[$config['driver']]($this->app, $config);
    }

    /**
     * Create an instance of the driver.
     *
     * @param  array  $config

View on GitHub (pinned to e0f6eb3518)