The Two Main Culprits for Your Laravel Dusk Tests Not Running

December 16th, 2024 • 1 minute read time

Despite Dusk integrating flawlessly with the Laravel framework, sometimes your tests just won't run.

And sometimes, your tests were previously running but have now decided not to run. Here are the two main issues I've experienced and how to solve them.

Usually, you'll get some variation of the following error message:

Failed to connect to localhost port 9515 after 0 ms: Couldn't connect to server

Let's fix it.

If you see Failed to connect to localhost port 9515 after 0 ms: Couldn't connect to server when running your Dusk tests, this could be due to a permissions error.

When Dusk runs, it'll execute the Chrome binaries in your project's vendor folder. If you haven't given the correct permissions to execute these, of course, it'll fail.

Run chmod to give the correct permissions to the bin (binary) directory of the Dusk dependency:

chmod -R 0755 vendor/laravel/dusk/bin/

If everything else is good, your tests should run without issues.

The second issue you may encounter is that your ChromeDriver binaries do not support the current version of Chrome installed on your system.

You'll probably see an error like this:

This version of ChromeDriver only supports Chrome version 90
Current browser version is 131.0.6778.140

To fix this, update the ChromeDriver version using the command line:

php artisan dusk:chrome-driver --detect

The --detect flag will detect which version of Chrome your system is running and match up the latest compatible version.

Once your ChromeDriver is up-to-date, you shouldn't see this issue any more.

If you found this article helpful, you'll love our practical screencasts.
Author
Alex Garrett-Smith
Share :

Comments

No comments, yet. Be the first!