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

Annaro's avatar

Dusk only runs on port 9515 ?!

Hi all,

I'm working on an automation system that uses Dusk in a controller.

The goal would be to make the app usable by several users at a time, and those users may launch sequences of actions that would take at least a few minutes to complete. It would be nice if users did not have to wait for the other users' processes to complete.

I'm not too sure how to do this (or if it's even doable, actually) but i was thinking it might help to run the treatment for each user on a different port, right? Easy to code.

Except that i can't get anything to work on any other port (that i tried) other than port 9515.

So here is my code to start and stop a browser (from a controller):

       $process = (new ChromeProcess)->toProcess();
        $process->start();

        $options = (new ChromeOptions)->addArguments(['--disable-gpu', '--no-sandbox']);
        $capabilities = DesiredCapabilities::chrome()->setCapability(ChromeOptions::CAPABILITY, $options);
        $driver = retry($times = 5, function () use($capabilities) {
            $port = 9515;
            return RemoteWebDriver::create('http://localhost:'.$port, $capabilities);
        }, $sleep = 500);


        $browser = new Browser($driver);

      
        $browser->quit();
        $process->stop();

It works like a charm, as long as i leave $port = 9515 As soon as i change to "9516" for example, i get this error:

Facebook\WebDriver\Exception\WebDriverCurlException
Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu","--no-sandbox"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"args":["--disable-gpu","--no-sandbox"]}}} Failed to connect to localhost port 9516: Connection refused

I checked if there was any process running on that port with command (i'm on a Mac) : sudo lsof -i :9516 Nothing. But it does not work. I tried with a bunch of other ports: 3000, 7000, 9517, 9518, 9519, 9520. Same thing. No process running on port, but the connection is refused.

So i thought i'd better check if it works with regular Dusk tests, right? So i modified DuskTestCase.php and TestCase.php to use port 9516, and i ran the browser tests: php artisan dusk. Same thing, connection refused.

What am i missing? Thank you!

0 likes
2 replies
Annaro's avatar

OK so i found out that there is still something running on port 9515, even if i try to start Dusk on another port. I figure it must be the Chrome driver that is still started on port 9515. I still don't know where to configure on which port the Chrome driver is started, but i'm looking in that direction now.

Please or to participate in this conversation.