Laravel Echo private channel: /broadcasting/auth returns 403
POST /broadcasting/auth 403 (Forbidden)Short answer
A 403 from /broadcasting/auth means Laravel refused the subscription. Either the request has no authenticated user for the guard in use, so the callback never runs, or the callback in routes/channels.php returned false for that channel. List the channels, then test the callback with the logged-in user.
Fix it fast
1Find out which cause you have
List the channel callbacks Laravel has registered and compare them to the channel name your frontend subscribes to.
php artisan channel:list2Match what you see, then jump to its fix
What does the error look like?
POST /broadcasting/auth 403 (Forbidden)
Cause 1 of 2
The request is not authenticated for the guard that authorizes channels
1Check
Private and presence channels authenticate with the default guard. If the user is not authenticated, authorization is denied and the callback is never executed.
php artisan tinker # then run: config('auth.defaults.guard')2Fix
Make sure the user is signed in with that guard when Echo connects, or name the guards the channel accepts.
Broadcast::channel('orders.{orderId}', function ($user, int $orderId) {
return $user->id === Order::findOrNew($orderId)->user_id;
}, ['guards' => ['web', 'admin']]);3Verify
Reload the page while signed in and watch the auth request return 200.
php artisan channel:listConfirmed by laravel.com
Cause 2 of 2
The authorization callback returns false
1Check
The callback must return true or false. A strict comparison between an integer and a string id, or a wrong owner column, returns false.
php artisan tinker
>>> $u = App\Models\User::first(); $o = App\Models\Order::first();
>>> $u->id === $o->user_id2Fix
Fix the comparison or the lookup in routes/channels.php so it returns true for the owner.
Broadcast::channel('orders.{order}', function (User $user, Order $order) {
return $user->id === $order->user_id;
});3Verify
Subscribe as the owner and as another user: the owner connects, the other gets 403.
php artisan channel:listConfirmed by laravel.com
How do I stop it coming back?
- Keep channel names in routes/channels.php and the frontend in step; list them with channel:list after every change.
- Add a feature test for each private channel with an owner and a stranger.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix