What are you using as server? Pusher? Laravel websockets (pusher replacement)?
Why have you set the host to 127.0.0.1?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using pusher for laravel and I want to test results in the localhost. there is some problems with it and I get "WebSocket is closed before the connection is established" error. my configurations are :
.env
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=local
PUSHER_APP_KEY=local
PUSHER_APP_SECRET=local
broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY' ),
'secret' => env('PUSHER_APP_SECRET' ),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
// 'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => false,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http'
],
],
bootstrap.js
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'local',
encrypted: false,
wsHost: window.location.hostname,
wsPort: 6001,
// wssPort: 6001,
disableStats: true,
transports: ['websocket']
});
I have search this error a lot on the internet but i haven't gotton any answeres to solve problem yet
Please or to participate in this conversation.