Search code examples
dockerwindows-subsystem-for-linux

How to fix "Failed to connect to localhost port 9515: Connection refused" Laravel Dusk


So I have been working with Laravel Dusk for around a couple of months now. But suddenly ran into an error:

Failed to connect to localhost port 9515: Connection refused

Which I know is a very common error and I have googled a lot with no solutions found as they all seem to be using homestead.

My setup: Windows 10 using WSL. I am using VSCode to run the tests using php artisan dusk --stop-on-error --stop-on-failure

I have not found any solutions that are related to Windows 10 without having homestead which I am not using.

The full error output is:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"w3c":false,"binary":"","args":["--disable-gpu","--headless","--window-size=1920,1080"]}}}

Failed to connect to localhost port 9515: Connection refused

I do believe that it has something to do with the chromedriver not working correctly as it does not even seem to start up, but I cannot be accurate with this statement. I am expecting that dusk would run a test and fail as I have not set the test up to pass.

Any help or guidance is really appreciated as I am very stuck!


Solution

  • So for anyone wondering why it was not working. For me, it was my own stupidity. I was trying to run firefox with geckodriver a couple of days ago and gave the wrong path to the wrong exe file, hence couldn't serve at all...