Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jordygroote's avatar

Socket is not connecting to 192.168.10.10:3000 using homestead and laravel and socket.io

From the server side everything is working fine:

var server = require('http').Server();

var io = require('socket.io')(server);

var Redis = require('ioredis');
var redis = new Redis();


redis.subscribe('test-channel');

redis.on('message', function (channel, message) {
    message = JSON.parse(message);

    console.log(channel + ':' + message.event);
    io.emit(channel + ':' + message.event, message);
});


/*Booting Up the Server : port 3000 */
server.listen(3000 , function(){
    console.log('The Server Is Running');
});  

Only on the client side it is not working.

   $(document).ready(function(){
        var socket = io.connect('http://192.168.10.10:3000');

        console.log(socket.connected);

        socket.on('test-channel:UserSignedUp', function(data) {
            console.log(data);
        });
    });

The console.log('socket.connected) return false all the time.

I followed this series: https://laracasts.com/series/real-time-laravel-with-socket-io/episodes/3?autoplay=true

How can i debug this? What am i doing wrong?

Thanks.

0 likes
3 replies
pasupathy's avatar

i am having the same problem, i am running on windows

pasupathy's avatar

i had even installed vagrant and homestead and it was giving the same problem, finally i used the latest version of socket.io 2.0.3 , and that really worked and mcstepp yes, its io(url)

so , just follow jeffrey's tutorial as it is and replace the socket.io version to the latest one in your client

Please or to participate in this conversation.