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

nickdavies07's avatar

Websockets Server on Homestead using Laravel Websockets

I'm using the beyondcode/laravel-websockets package and I'm trying to start the websockets server on Homestead.

I've SSH'd into Homestead and ran php artisan websockets:serve command to start the server however it keeps throwing back an error saying the address is already in use.

$ php artisan websockets:serve
Starting the WebSocket server on port 6001...

   RuntimeException  : Failed to listen on "tcp://0.0.0.0:6001": Address already in use

  at /home/vagrant/code/websockets/vendor/react/socket/src/TcpServer.php:164
    160|             \STREAM_SERVER_BIND | \STREAM_SERVER_LISTEN,

A quick check with sudo lsof -i -P -n | grep LISTEN shows the vagrant php service is using the port. How would I change the port for websockets, is it just as simple as changing the port in broadcasting.php and restarting the server?

0 likes
1 reply
nickdavies07's avatar
nickdavies07
OP
Best Answer
Level 8

Update: it is that simple. Passing the --port={port} parameter when using php artisan websockets:serve allows a different port to be used.

Please or to participate in this conversation.