Could not bind to tcp://127.0.0.1:8080: Address already in use

Moe picture Moe · Mar 20, 2014 · Viewed 6.9k times · Source

After developing most of the site, I needed to introduce the ability to push data from the server to client. After some research I decided to use Ratchet (I'm using Laravel 4.1).

I've implemented my pushUpdate class, but I'm having issue starting the webSocket server, My current approach to start the server is:

    // Run the server application through the WebSocket protocol on port 8080
    $app = new Ratchet\App('localhost', 8080);
    $app->route('/update', new pushUpdate);
    $app->route('/echo', new Ratchet\Server\EchoServer, array('*'));
    $app->run();

This code is ran when the page that requires push update is requested. This is the error I receive:

   React \ Socket \ ConnectionException
   Could not bind to tcp://127.0.0.1:8080: Address already in use

I haven't implemented a webSocket before, I've read the server config doc (http://socketo.me/docs/deploy#serverconfiguration) which states I can run both web and socket servers on port 8080.

any help to solving this is highly appreciated.

Answer

shucklak picture shucklak · Mar 20, 2014

Sounds like you have a process already using port 8080. You can see if that is the case by using "netstat -ap" to see what process is using 8080.